Page 1 of 1
Need help with checkbox form
Posted: Tue Mar 23, 2004 7:31 am
by Stryks
I need to create a form with a series of checkboxes, one for each entry in a table in a mySQL database.
I'm wondering if anyone can give me some idea of the best way to convert a returned list of values into a list of checkboxes which will add more checkboxes automatically if needed.
Also, once the values have been updated by the checkboxes, what is the best way to write them back?
Any help or ideas of where to start would be great. Thanks.
Posted: Tue Mar 23, 2004 7:45 am
by magicrobotmonkey
I have a page with a list of quesitons that each have a radio button for yes,no, or n/a. I keep track of it by having a no_string and a na_string which each of which is simply a list of numbers, if question seven was answered na, then the na_string gets a 7. so then I check to see if each nymber is in either string. if its not, then its assumed yes. Does that help?
Posted: Tue Mar 23, 2004 5:17 pm
by tim
you'll need a form, a while loop, and to create the form into an array so when multiples check boxes are selected, each retaining variable for each checked box is transfered.
Posted: Tue Mar 23, 2004 9:31 pm
by Stryks
Thanks for the feedback, but I'm still not sure I understand fully.
Starting with first things first ... writing the boxes to the form. The number of checkboxes will depend on how many records there are that match the users ID, so the number will be different for everyone.
With this in mind, how should I go about naming the checkboxes? I had thought like 'item[1] item[2]' etc. But that doesnt appear to work at all.
How should I name them, and how can I keep track of the corellation of checkboxes to database options?
Thanks
Posted: Tue Mar 23, 2004 9:34 pm
by joespenceley
working on a very similar form myself and i hope to complete it tonight. if i get the damn thing working i will let you know how.
Posted: Wed Mar 24, 2004 4:13 pm
by tim
well what exactly kind of info do u wish to display (with a checkbox beside it)
is that info in the db? also, what do u plan to do with taht info when checked? delete it, edit it? send it to a different page?
let me know