30, August 2008

Checkboxes working but cannot get radio groups working - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Validate_fields Class (Moderator: Olaf)
Topic: Checkboxes working but cannot get radio groups working
« previous next »
Pages: [1] Print

Author Topic: Checkboxes working but cannot get radio groups working  (Read 748 times)
I crack Photoshop!
*
Posts: 3
22 credits
Members referred : 0


« on: Sep 21, 2007, 04:43:16 PM »

I have been through the demo, worked on the examples, but just cannot get radio buttons to work correctly, have any body managed to get that right.
Checkboxes no problem, but the radio is getting the better of me. Is there someone whom had the same problem that got it to work.

It would be much appreciated.
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Sep 21, 2007, 08:42:10 PM »

Huh those two types of elements are almost the same (actually much easier). Please give an example


Last blog : Is your website is down? Know before your visitors do!
I crack Photoshop!
*
Posts: 3
22 credits
Members referred : 0


« Reply #2 on: Dec 06, 2007, 01:22:13 PM »

My apologies for only getting back so long afterwards. Embarrassed
If we implement the radio as per the example, it works. The only problem is should the user fail to complete any other field
and the form refresh and output the error, the radio button selection defaults to the last radio field. So if I selected Yes, then it will jump and select Maybe as checked.
This also happens on the submit. Some guidance on where im making my mistake will be much appreciated.

We have used the following code:
In the validation I set the following:
   $example->add_check_box("Radio button test", "choice", "radio", "");

And in the form I have used:
   <label for="choice">A Radio (required)</label>
   Yes <input name="choice" type="radio" id="check" value="y"<?php if (isset($_POST['choice'])) echo " checked"; ?>>
   No <input name="choice" type="radio" id="check" value="n"<?php if (isset($_POST['choice'])) echo " checked"; ?>>
   Maybe <input name="choice" type="radio" id="check" value="m"<?php if (isset($_POST['choice'])) echo " checked";?>><br clear="all">
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Dec 06, 2007, 01:37:53 PM »

don't check only for an exsiting value but also what value is available

like
if (isset($val) && $val == 'some value') echo 'yes';


Last blog : Is your website is down? Know before your visitors do!
I crack Photoshop!
*
Posts: 3
22 credits
Members referred : 0


« Reply #4 on: Dec 06, 2007, 02:02:40 PM »

Thanks so much , especially for the very swift response, its much appreciated. For the benefit of the community, we have amended the code to the following and it works great! Many thanks again. Such a quick fix, don't know how we missed that.

<label for="choice">A Radio (required)</label>
   Yes <input name="choice" type="radio" id="check" value="y"<?php if (isset($_POST['choice']) && $_POST['choice'] == 'y') echo " checked"; ?>>
   No <input name="choice" type="radio" id="check" value="n"<?php if (isset($_POST['choice']) && $_POST['choice'] == 'n') echo " checked"; ?>>
   Maybe <input name="choice" type="radio" id="check" value="m"<?php if (isset($_POST['choice']) && $_POST['choice'] == 'm') echo " checked"; ?>><br clear="all">
Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6301
38632 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Dec 06, 2007, 02:25:38 PM »

you're welcome I think people like this solution much more Cheesy

http://www.finalwebsites.com/snippets.php?id=48 Visit through proxy


Last blog : Is your website is down? Know before your visitors do!
Just another rainy day
*
Posts: 1
6 credits
Members referred : 0


« Reply #6 on: Dec 22, 2007, 09:21:29 PM »

Hi ,
i have a group of radio input bet i have a problem when i submitted the form if i have selected second radio input validation returns with error;but if i have selected the first radio input everyting is okay.

i have used the class like this

$example->add_check_box("Example", "test", "radio","");

<input name="test" type="radio" id="test" value="1" <?php if (isset($_POST['test']) && $_POST['test'] == '1') echo " checked"; ?> />No
     
<input name="test" type="radio" id="test" value="0" <?php if (isset($_POST['test']) && $_POST['test'] == '0') echo " checked"; ?> /Yes
   
I don't understand where is the problem...

EDIT
I solved the problem radio inputs value = 0 giving errors i changed values 1 and 2 so its worked...
« Last Edit: Dec 22, 2007, 09:54:34 PM by mmccss »
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7141
Tags : Validate_fields Class php validation finalwebsites Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP  >  PHP classes @finalwebsites.com  >  Validate_fields Class (Moderator: Olaf)
Topic: Checkboxes working but cannot get radio groups working
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Aug 30, 2008, 05:02:02 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.192
Total Topics: 7.462
Total Members: 3.866
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: shopforindia

33 Guests, 4 Users online :

14 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.