| Author |
Message |
killing-hours RavenNuke(tm) Development Team

Joined: Oct 01, 2010 Posts: 415 Location: Houston, Tx
|
Posted:
Wed Feb 16, 2011 3:45 pm |
|
Hey all-
I've been at this for a couple days now and I'm so hung up on stupid checkboxes. Maybe one of you will have a better idea of how to handle this before I spill my brains on a wall.
I'm setting a switch of sorts for my system and I'm trying to do it with a form that links checkboxes back to a database. The way the form is created on the page is to run through a while loop and create a table row with the company name and checkbox.
What I can't figure out is how this checkbox is to be "unique" so that when the form is submitted I can switch one of the fields in the database from 0 to 1 or visa verca.
-------------------------
Here's the flow.
3 fields in database: ID, Name, Active
Form is built with "while(list" loop creating a new table row and td's for the table row.
| Code: | while(list($id, $name, $active) = $db->sql_fetchrow($query)) {
echo '<tr><td>'.$name.'</td>';
echo '<td align="center"><input type="checkbox" name="chk" /></tr>';
}; |
the "Active" field will need to switch from 0 -> 1 or 1 -> 0 based on checkbox status.
------------------------
Any insight or help will be appreciated. Thanks. |
|
|
|
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
|
Posted:
Wed Feb 16, 2011 7:39 pm |
|
| Code: | | name="chk' . $id .'" |
|
|
|
|
 |
killing-hours RavenNuke(tm) Development Team

Joined: Oct 01, 2010 Posts: 415 Location: Houston, Tx
|
Posted:
Thu Feb 17, 2011 8:33 am |
|
Right... I tried that Palbin...
Here's the problem with doing it that way though. As the table fills with more companies... I would have to go back re-program the actual submit script to catch the individual "$_POST['chkID']" ....unless there is some other way to pick them up in the script I'm unaware of.
This is one of those types of things that will need to work all on it's own and shouldn't have to be reprogrammed as the table expands. |
Last edited by killing-hours on Thu Feb 17, 2011 11:39 am; edited 1 time in total |
|
|
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
|
Posted:
Thu Feb 17, 2011 11:07 am |
|
| Code: | | name="chk[' . $id .']" |
Then just iterate through the array when the form i submitted. |
|
|
|
 |
killing-hours RavenNuke(tm) Development Team

Joined: Oct 01, 2010 Posts: 415 Location: Houston, Tx
|
Posted:
Thu Feb 17, 2011 11:28 am |
|
Holy cow... that Idea never even crossed my mind. I was trying to figure out on the script side how to work with an array but nothing seemed plausible. I'll try this when I get a chance and appreciate your insight bud!
on a side note... Did you happen to determine if ajaxModules was safe for use or not? |
|
|
|
 |
Palbin Site Admin

Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
|
Posted:
Thu Feb 17, 2011 7:02 pm |
|
It seems safe. Since it is on the admin side it does not have to be perfect as normal users can not access it. |
|
|
|
 |
|
|
|
|