ashishrathore
01-20-2006, 10:12 AM
hi,
i am having prob regarding checking all/none checkboxes
here is a snapshot of that page that i want to refer
Select Category :
cat1 subcat11 subcat12
cat2 subcat21 subcat22 subcat23
cat3 subcat31 subcat323
cat5 subcat51 subcat52 subcat53 subcat54
cat9 subcat91 subcat92
all the cat[i] are main categories and in front of that there are corrosponding subcategories subcat[i]
what i want is when i select a cat[i] then all the corrosponding subcat[i] must be selected
mind u the problem is that all these categories and the subcategories are dynamically taken from a text file so it is not fixed for a certain number of lines.
i had created the function using JS for this but when i select any cat[i] all the subcat[i] of all the categories are selected, so i want only the corrosponding subcat[i] to be selected and not the all subcat[i].
here is my JS function
function checkAll(checkname, exby)
{
for (i = 0; i < checkname.length; i++)
checkname[i].checked = exby.checked? true:false
} //////// but it check all the subcategories and not the corrosponding subcat[i].
the code 4 checkboxes is smthng like this.....
<input type=checkbox name="main[]" value="<?php echo "$mainh"; ?>" onClick="checkAll(document.pform.sub,this)"> ///this is the main category part
<input type=checkbox name="sub" value="<?php echo "$subname"; ?>"><?php echo "$sub"; ?> /////this is 4 generating subcategories.
plz help me....
-ashish
i am having prob regarding checking all/none checkboxes
here is a snapshot of that page that i want to refer
Select Category :
cat1 subcat11 subcat12
cat2 subcat21 subcat22 subcat23
cat3 subcat31 subcat323
cat5 subcat51 subcat52 subcat53 subcat54
cat9 subcat91 subcat92
all the cat[i] are main categories and in front of that there are corrosponding subcategories subcat[i]
what i want is when i select a cat[i] then all the corrosponding subcat[i] must be selected
mind u the problem is that all these categories and the subcategories are dynamically taken from a text file so it is not fixed for a certain number of lines.
i had created the function using JS for this but when i select any cat[i] all the subcat[i] of all the categories are selected, so i want only the corrosponding subcat[i] to be selected and not the all subcat[i].
here is my JS function
function checkAll(checkname, exby)
{
for (i = 0; i < checkname.length; i++)
checkname[i].checked = exby.checked? true:false
} //////// but it check all the subcategories and not the corrosponding subcat[i].
the code 4 checkboxes is smthng like this.....
<input type=checkbox name="main[]" value="<?php echo "$mainh"; ?>" onClick="checkAll(document.pform.sub,this)"> ///this is the main category part
<input type=checkbox name="sub" value="<?php echo "$subname"; ?>"><?php echo "$sub"; ?> /////this is 4 generating subcategories.
plz help me....
-ashish