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:
Posts: 6301
38632 credits Members referred : 374
It's time to use PHP5!
« Reply #1 on: Sep 21, 2007, 08:42:10 PM »
those two types of elements are almost the same (actually much easier). Please give an example
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. 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:
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';
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.
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.