php - How does form buttons can select checkboxes in the next page? -
i have buttons in first_page.php, , checkboxes in second_page.php.
need select corresponding checkbox query string this:
when "first value button" pressed --> "second_page.php" "my first value" checkbox selected.
first_page.php :
<form action="second_page.php"> <input class="btn" type="submit" value="first value button"> <input class="btn" type="submit" value="second value button"> <input class="btn" type="submit" value="third value button"> </form>
second_page.php :
<form name="name" method="post" action="#"> <input type="checkbox" name="mybox[]" value="my first value"/> <span>my first box</span><br /> <input type="checkbox" name="mybox[]" value="my second value"/> <span>my second box</span><br /> <input type="checkbox" name="mybox[]" value="my third value"/> <span>my third box</span><br /> </form>
you have specify name each input connect $_post
in second_page.php
have fetch form value. in first_page.php:
<form action="second_page.php" method="post"> <input name="first_value_btn" class="btn" type="submit" value="first value button"> <input name="second_value_btn" class="btn" type="submit" value="second value button"> <input name="third_value_btn" class="btn" type="submit" value="third value button"> </form>
in second_page.php :
<input type="checkbox" name="prodotti[]" value="my first value" <?php echo ( isset($_post['first_value_btn']) ? 'checked="checked"' : '');?> />
i've used post
method in example above, use get
instead , replacing $_post
$_get
instead.
Comments
Post a Comment