Jump to content

Archived

This topic is now archived and is closed to further replies.

dmacman

Can you retain a radio buttons position in an array?

Recommended Posts

Hi All,

I am trying to do several forms with dynamic radio buttons ( I would use checkboxes, but I want to limit them to only one selection per item).

I can build the form dynamically and get the data, but I want to retain the position of the radio button in an array (to insert into my table).

IE...

|---Radio Button 1-|-Radio Button 2--|-Radio Button 3--|
|-----------------------|-----Selected--------|--------------------|

[Radio Button] => Array
(
[0] => 0
[1] => 1
[2] => 0
)


Again, If I could limit the users selection to one checkbox, I would just to pull off this positioning in the array I am trying to achieve.

Is this even possible?

Thanks,

Don

Share this post


Link to post
Share on other sites
Don't understand your problem.

Are you having a problem when creating the form and showing the correct button as selected?

Share this post


Link to post
Share on other sites
Hi Barand,

The problem I have is I am making a list of 45 celebrities and creating the 'poll' dynamically. I setup the choices as radio buttons so they can only vote for 1 category. But my table is setup with a different field for each category ( I now know this is not efficient and I am working on an enum field to store the votes).

I could have used checkboxes, but without a javascript snippet, they could chose all the categories (and the checkbox method would make the array easy to store in my current table layout).

What I was trying to do is save the position (of chosen category) and store it in that field along with a 'zero' for the non-chosen categories.

I don't know i that is even possible, but would like to know, just for knowledge sake.

Does that make more sense?

Thanks,

Don

Share this post


Link to post
Share on other sites
Okay, I think I understood.

Simple give the radio groups different names:

[code]<input type="radio" name="group1" value="value1"> Value 1 for Group 1
<input type="radio" name="group1" value="value2"> Value 2 for Group 1
<input type="radio" name="group1" value="value3"> Value 3 for Group 1

<input type="radio" name="group2" value="value1"> Value 1 for Group 2
<input type="radio" name="group2" value="value2"> Value 2 for Group 2
<input type="radio" name="group2" value="value3"> Value 3 for Group 2[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.