Getting Form Variables
Posted: Sun Nov 23, 2003 8:13 pm
Ok, here's the problem. A script is pulling fields (help desk categories) from a database and displaying them on the screen in a checkbox fashion. You can then check the box to determine who can see these fields (similar to the departments in PerlDesk). The problem is that the number of categories can change as the admin adds and deletes them. So I'm trying to create a script that will display the choices and save information. What I had didn't work so someone suggested the following:
This is in a loop that draws checkboxes and assigns the checked value to $hd_cat_id based on the information it pulls from the category HD. There could be anywhere from 1 to 20 or more boxes. It' all depends on how many categories are entered into the HD.
This is supposed to read each variable and print it to the screen, provided it was checked. In the final version I'll do something with the information, the print is just to make sure it's doing what it's supposed to be doing. $total_count is passed from the calling form as the total categories displayed.
If I select all the boxes then the output is something like this
1 - 1 .. 2 - 1 .. 3 - 1
But the data that's stored in $cat_check[$counter] (the hd_cat_id) isn't 1. At least not for all the fields, maybe one of them is.
It should look something like:
1 - 1 .. 2 - 4 .. 3 - 10.. where the second number is the hd_cat_id.
Any suggestions would be helpful.
This is in a loop that draws checkboxes and assigns the checked value to $hd_cat_id based on the information it pulls from the category HD. There could be anywhere from 1 to 20 or more boxes. It' all depends on how many categories are entered into the HD.
Code: Select all
print "$default_right_line<input name="cat_check[]" type="checkbox" value="$hd_cat_id">Check to Allow</font></font></font></div></td>";Code: Select all
for ($counter = 1; $counter <= $total_count; $counter++)
{
$cat_check[$counter]=(bool)(isset($_POST['cat_check'][$counter]));
print "$counter - $cat_check[$counter] .. ";
}
die();If I select all the boxes then the output is something like this
1 - 1 .. 2 - 1 .. 3 - 1
But the data that's stored in $cat_check[$counter] (the hd_cat_id) isn't 1. At least not for all the fields, maybe one of them is.
It should look something like:
1 - 1 .. 2 - 4 .. 3 - 10.. where the second number is the hd_cat_id.
Any suggestions would be helpful.