black.horizons Posted July 17, 2007 Share Posted July 17, 2007 hi all, i have a datagrid (several columns of arrays). submitting values from textboxes is fine, as submitted values are related to each row (i.e. for row1 if text entered is "boo" then that is what is returned for row1.) however i have tried to implement checkboxes and have discovered that if you tick the box for row 5 and non of the four preceding rows, then what is returned says row1 has the box ticked. this i gather is from the checkbox not submitting a value if it is not ticked. is there a way round this? that explanation was totally pants, and if anybody understands it i for one will be amazed!! tia - alex Quote Link to comment Share on other sites More sharing options...
akitchin Posted July 17, 2007 Share Posted July 17, 2007 the problem is exactly as you suspect - a checkbox will only send its value if it is checked. to amend this, you'll probably either want to explicitly state the array key in the name of the checkbox, or specify the unique indentifier in the value it passes back: <input type="checkbox" name="ticked[5]" value="row5" /> by the way, have a look around - there are people FAR worse at explaining their problem than you. Quote Link to comment Share on other sites More sharing options...
black.horizons Posted July 18, 2007 Author Share Posted July 18, 2007 worked a treat. i had the rows displaying in a foreach loop - as the number of rows was determined frmo the number of results returned from a mysql table. for anybody else with a similar problem in future after the "while" line put "$i=0;" at the end of your foreach loop (i.e. before the "}" put "$i++;". Insert " <input type="checkbox" name="ticked[$i]" " where appropriate. Many thanks akitchin. I knew what I needed and what the problem was, just wasn't aware I could state the array key explicitly. Come to think of it I should have known this ... no matter. 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.