Saturday, 24 December 2016

Send/receive Multiple Checkboxes Value on Another Page in PHP

Some time we require to populate multiple checkboxes on web page and send these values to another page or save in database. foe example some time we get the list of students from database and take their attendance by just clicking checkboxes for them.

How to create multi select checkboxes? see the example by clicking here.

To create multiple checkboxes use following code

<form id="xyz" action="2.php" method="post" target="">
<input name='rid[]' type='checkbox' class='checkbox' value="1" />
<input name='rid[]' type='checkbox' class='checkbox' value='2' />
<input name='rid[]' type='checkbox' class='checkbox' value='3' />
<input name='rid[]' type='checkbox' class='checkbox' value='4' />
 <input type="submit" name="submit" value="Get Selected Certificates" />
</form>



On the another page receive the value of checkboxes using PHP code


        if(!empty($_POST['rid'])) 
        {
                echo "<h2> You have selected: </h2>";
                foreach($_POST['rid'] as $chvalue)
              {
                echo $chvalue;

               }
        }



No comments:

Post a Comment

Change image source dynamically on hyperlink

 Changing image source dynamically using JQuery. Here in this example I have created there hyperlink and stored all images in the same folde...