Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

multiple checkbox select with javascript and getting checkbox Value using php




<title>




multiple checkbox select with javascript and getting checkbox Value  
</title>
<script type="text/javascript">
function checkAll(parent, field)
{
    var children = document.getElementsByName(field);
 
    var newValue = parent.checked;
    for (i = 0; i < children.length; i++){
        children[i].checked = newValue;
    }
}
</script>
<form method="post" action="">

<table>

<tr>
    <td>
        <label for="Select All State of India">Select All State of India </label>
        <input name="county[]" value="india" type="checkbox"  onChange="checkAll(this, 'townI[]')" />
   </td>

  <td>
  <label for="Select All City of Gujrat">Select All City of Gujrat</label>
  <input name="state[]" value="gujrat" type="checkbox"  onChange="checkAll(this, 'townG[]')" />
  </td>

  <td>
  <label for="Select All Games">Select All Games</label>
  <input name="games[]" value="games" type="checkbox"  onChange="checkAll(this, 'townM[]')" />
  </td>

</tr>


<tr>
    <td>
    <label for="Gujrat">Gujrat</label>
    <input name="townI[]" value="gujrat" type="checkbox"  />
    </td>
 </tr>

<tr>
    <td>
    <label for="Maharastra">Maharastra</label>
    <input name="townI[]" value="maharastra" type="checkbox"  />
    </td>
</tr>

<tr>
    <td>
    <label for="kasmir">kasmir</label>
    <input name="townI[]" value="kasmir" type="checkbox"  />
    </td>
  </tr>
 
 
 
<tr>
    <td>
    <label for="Ahmedabad">Ahmedabad</label>
    <input name="townG[]" value="ahmedabad" type="checkbox"  />
    </td>
</tr>

 <tr>
    <td>
    <label for="Rajkot">Rajkot</label>
    <input name="townG[]" value="rajkot" type="checkbox"  />
    </td>
 </tr>

  <tr>
    <td>
    <label for="baroda">baroda</label>
    <input name="townG[]" value="baroda" type="checkbox"  />
    </td>
  </tr>


  <tr>
    <td>
    <label for="Cricket">Cricket</label>
    <input name="townM[]" value="cricket" type="checkbox"  />
    </td>
</tr>

 <tr>
    <td>
    <label for="valleyBall">valleyBall</label>
    <input name="townM[]" value="valleyBall" type="checkbox"  />
    </td>
  </tr>

  <tr>
    <td>
    <label for="FootBall">FootBall</label>
    <input name="townM[]" value="FootBall" type="checkbox"  />
    </td>
  </tr>




 


</table>
<input type="submit" name="submit" value="check it" />

<?php  

if(isset ($_POST['submit']))
{
$townF =   $_POST['townI'];
$townG =   $_POST['townG'];
$townM =   $_POST['townM'];

$checked_country = implode(',',$townF);
$checked_state = implode(',',$townG);
$checked_games = implode(',',$townM);

echo "</br>";
echo "selected Country :- ".$checked_country;

echo "</br>";
echo "selected State :- ".$checked_state;

echo "</br>";
echo "selected Games :- ".$checked_games;

}
?>

</form>





0 komentar:

Post a Comment

multiple checkbox select with javascript and getting checkbox Value using php