prometheos Posted March 25, 2010 Share Posted March 25, 2010 Hi, i have 2 arrays of checkboxes and i want it so that when i check 1, the same index of the other 1 is unchecked... any ideas how to do this? here's the way i have it set up? if(($xml->item[$n-1]->requested->confirmed == "") &&($xml->item[$n-1]->requested->by != "") ){ echo '<td><center><input type="checkbox" name="confirmItems[]" value="'.$itemString.' onCheck = " " "/></center></td>'; echo '<td><center><input type="checkbox" name="denyItems[]" value="'.$itemString.'"/></center></td>'; } What should i do in the onCheck? this is inside a foreach loop by the way. thanks for the help Quote Link to comment Share on other sites More sharing options...
tekrscom Posted March 25, 2010 Share Posted March 25, 2010 You need JavaScript help, not PHP... Quote Link to comment Share on other sites More sharing options...
andrewgauger Posted March 25, 2010 Share Posted March 25, 2010 I don't know why you are using an array to define the checkboxes, but that is the fist change I'd make: <input type="checkbox" name="confirmItems" value="'.$itemString.' onCheck = " " "/> Then I'd take into consideration that not all browsers will display the value="" portion: <input type="checkbox" name="confirmItems[]" value="'.$itemString.' onCheck = " " ">'.$itemString.'</input> Then the javascript you need would look like: <script language="javascript"> function uncheck(src,element) { if (src.checked==true) { element.checked=false } } </script> <form name="request"> <input type="checkbox" name="confirm" onClick="uncheck (this,document.request.deny)">confirm</input> <input type="checkbox" name="deny" onClick="uncheck(this,document.request.confirm)">deny</input> </form> [code] I didn't bother to convert this into php, so when you copy and paste put it into a htm file and then make the mods to get it going in php. The only difference between this and a radio object is that once you select one, you can make the decision to clear both--if this is not the behavior you want look into the radio object. 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.