medj Posted June 27, 2008 Share Posted June 27, 2008 Hi everyone, hopefully there is an easy solution to my problem. I have spent the better part of the day trying to get my script to work. I have gotten pretty far but have just hit a fork in the road. Let me explain: I have a database and I list all the rows of the table with a checkbox on the left of each row. The checkbox is mainly an indicator whether that item (row) is important or not. So basically I created a checkbox array. Here is a part of my code: <input name='track_stock[]' type='hidden' value='off'><input name='track_stock[]' type='checkbox' value='on' " . ( ($row[trackstock] == 'on') ? " CHECKED" : "") ."> You will notice the hidden field that appears before the checbox. I had to search forever to fix that first problem where I found out only checkboxes that were checked were being sent with the form. The problem I have now is that the checkbox values are being sent twice for each row. Once for the hidden value and one for the checkbox value. So my checkbox values go into the database as either 'on' or 'off'. Just to tell you an example, if I select the first checkbox and click submit I get: off on off off off off.... If I select the first two, I get: off on off on off off off off... Maybe there is an easier way to do this. Anyone can help me please? Link to comment https://forums.phpfreaks.com/topic/112251-checkbox-array-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.