Jump to content

assign values to checkbox


ma5ect

Recommended Posts

HI all,

 

I have assigned a value to a check box but is it possible to have 2 values for one check box and then later display both values..

 

<input name="modulename[]" type="checkbox" value="<?php echo $row_Recordset2['Module name']; ?>" />
            <input type="checkbox" value="<?php echo $row_Recordset2['Scheduled']; ?>" name="modulename[]6" />

Link to comment
Share on other sites

the short answer is no, unless you put both values into the value attribute of the one checkbox.  alternatively, you can manually specify the index of the element(s) so that you have a structured array sent back to you:

 

<input name="modulename[0][0]" type="checkbox" value="<?php echo $row_Recordset2['Module name']; ?>" />
<input name="modulename[0][1]" type="checkbox" value="<?php echo $row_Recordset2['Scheduled']; ?>" />

<input name="modulename[1][0]" type="checkbox" value="<?php echo $row_Recordset2['Module name']; ?>" />
<input name="modulename[1][1]" type="checkbox" value="<?php echo $row_Recordset2['Scheduled']; ?>" />

 

although to be honest, it's not clear what you're trying to achieve.  a bit more explanation might be in order if this doesn't help you.

Link to comment
Share on other sites

Other alternatives:

 

- You can make the values a string with a separator like "val1|val2" and then explode at the |

 

- You can make one of the values the index name to modulename, if they are unique to each choice.

<input name="modulename[val1a]" type="checkbox" value="val2a" />

<input name="modulename[val1b]" type="checkbox" value="val2b" />

 

- You can have a hidden field for each checkbox named something associated with the checkbox (so you know which one to match it up to)

 

- Same thing as ^ but use sessions

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.