Page 1 of 1

How to Differentiate in groups of checkboxes

Posted: Wed Feb 09, 2005 6:48 am
by itsmani1
Hi every One !

i have problem in fetching in retriving values using post method.
like here is some code:

Code: Select all

<form name="form1" method="post" action="2ndpage.php">
  <table width="100%" border="0" cellspacing="1" cellpadding="1">
    <tr> 
      <td> 
        <input name="1" type="checkbox" id="1" value="checkbox">
        one</td>
    </tr>
    <tr> 
      <td>
        <input name="2" type="checkbox" id="2" value="checkbox">
        two</td>
    </tr>
    <tr> 
      <td> 
        <input name="3" type="checkbox" id="3" value="checkbox">
        three</td>
    </tr>
    <tr> 
      <td>
        <input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>
</form>
now on the 2ndpage.php

i want to fetch only thoese values that are checked
problme is that i have 2 types of check boxes
and i want to decide that the check box is checked or not and 2nd thing that i want to differentiate that checkbox belonges to which group.

Help Please ::

Posted: Wed Feb 09, 2005 7:03 am
by n00b Saibot
you should change the value parameter of input tag to reflect the group you want that checkbox in.

secondly change value="checkbox" to value="checkbox[]" so that an array of only selected checkboxes is sent.

Posted: Wed Feb 09, 2005 7:06 am
by itsmani1
n00b Saibot wrote:you should change the value parameter of input tag to reflect the group you want that checkbox in.

secondly change value="checkbox" to value="checkbox[]" so that an array of only selected checkboxes is sent.
thanks for the suggestion man 2nd thing is that i know there should be a name for checkbox that was just to show.
secondly change value="checkbox" to value="checkbox[]" so that an array of only selected checkboxes is sent.

Posted: Wed Feb 09, 2005 7:18 am
by djot
-
Hi,

Code: Select all

<form name="form1" method="post" action="2ndpage.php"> 
  <table width="100%" border="0" cellspacing="1" cellpadding="1"> 
    <tr> 
      <td> 
        <input name="checkbox_type1&#1111;]" type="checkbox" id="1" value="checkbox"> 
        one</td> 
    </tr> 
    <tr> 
      <td> 
        <input name="checkbox_type1&#1111;]" type="checkbox" id="2" value="checkbox"> 
        two</td> 
    </tr> 
    <tr> 
      <td> 
        <input name="checkbox_type2&#1111;]" type="checkbox" id="3" value="checkbox"> 
        three</td> 
    </tr> 
    <tr> 
      <td> 
        <input name="checkbox_type2&#1111;]" type="checkbox" id="4" value="checkbox"> 
        three</td> 
    </tr> 
    <tr> 
      <td> 
        <input type="submit" name="Submit" value="Submit"></td> 
    </tr> 
  </table> 
</form>


With name="checkbox_typeX[]" you will get your data as ARRAY. Now you can check whether the checked data/box is in array_type1 or array_type2.

djot
-

Posted: Wed Feb 09, 2005 7:18 am
by n00b Saibot
does that solve ur prob or there is something else in this matter