Jump to content

Can you retain a radio buttons position in an array?


dmacman

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
Link to comment
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
Link to comment
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.