ma5ect Posted November 26, 2008 Share Posted November 26, 2008 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" /> Quote Link to comment Share on other sites More sharing options...
akitchin Posted November 26, 2008 Share Posted November 26, 2008 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. Quote Link to comment Share on other sites More sharing options...
ma5ect Posted November 26, 2008 Author Share Posted November 26, 2008 I want the two fields data to be displayed with one check box... Quote Link to comment Share on other sites More sharing options...
.josh Posted November 26, 2008 Share Posted November 26, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.