NAVIGATION TO DIFFERENT PAGES BASED ON MULTIPLE RADIO BUTTON OPTION SELECTION |
NAVIGATION TO DIFFERENT PAGES BASED ON MULTIPLE RADIO BUTTON OPTION SELECTION |
shankar from vizag |
May 24 2019, 04:42 AM
Post
#1
|
Advanced Member Group: Members Posts: 202 Joined: 18-June 13 Member No.: 19,316 |
Greetings
1. I have 5 different php pages. 2. On first page, I have 2 sets of options, each set consists 2 radio buttons. The 2 sets of options are different in nature. Basing on the selection of two different sets of options I need to navigate the 2nd to 5 pages. I tried with php and javascript but I failed in both. my 1st page consists, <h3>Cause for:</h3><br> <input type="radio" name="cause" id="visit" value="VISIT"> VISIT <br> <input type="radio" name="cause" id="meeting" value="MEETING"> <h3>Type</h3><br> <input type="radio" name="type" id="enter" value="ENTERTAINMENT"> ENTERTAINMENT <input type="radio" name="type" id="misc" value="MISCELLANEOUS"> MISCELLANEOUS <input type="submit" name="submit1" value="SUBMIT"> If I opt value visit and entertainment ----> page2.php should open if I opt value visit and miscellaneous -------> page3.php should open if I opt value meeting and entertainment -----> page4.php should open if I opt value meeting and miscellaneous ------> page5.php should open Kindly guide me to do this. |
Christian J |
May 24 2019, 12:22 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,653 Joined: 10-August 06 Member No.: 7 |
Why not an ordinary data table with links:
CODE <table border=1> <tr> <td></td> <th>Visit</th> <th>Meeting</th> </tr> <tr> <th>Entertainment</th> <td><a href="">Visit Entertainment</a></td> <td><a href="">Visit Miscellaneous</a></td> </tr> <tr> <th>Miscellaneous</th> <td><a href="">Meeting Entertainment</a></td> <td><a href="">Meeting Miscellaneous</a></td> </tr> </table> ? The above is easy to understand, and you only need to click one link (as opposed to clicking two radio buttons and one submit button). If you must use radio buttons, I'd go with PHP (javascript has no advantages). Use a GET form in the default page, and check each querystring combination with IF/ELSE conditions (including one condition for a missing or invalid querystring). Then you could either let the same PHP script generate the different kinds of content, or generate redirect headers to separate pages. Also, if you use radio button it's good usability practice to give them a default state. |
shankar from vizag |
May 26 2019, 06:51 AM
Post
#3
|
Advanced Member Group: Members Posts: 202 Joined: 18-June 13 Member No.: 19,316 |
Why not an ordinary data table with links: CODE <table border=1> <tr> <td></td> <th>Visit</th> <th>Meeting</th> </tr> <tr> <th>Entertainment</th> <td><a href="">Visit Entertainment</a></td> <td><a href="">Visit Miscellaneous</a></td> </tr> <tr> <th>Miscellaneous</th> <td><a href="">Meeting Entertainment</a></td> <td><a href="">Meeting Miscellaneous</a></td> </tr> </table> ? The above is easy to understand, and you only need to click one link (as opposed to clicking two radio buttons and one submit button). If you must use radio buttons, I'd go with PHP (javascript has no advantages). Use a GET form in the default page, and check each querystring combination with IF/ELSE conditions (including one condition for a missing or invalid querystring). Then you could either let the same PHP script generate the different kinds of content, or generate redirect headers to separate pages. Also, if you use radio button it's good usability practice to give them a default state. Greetings Christian J. I tried with your idea of putting in table but it does't look that much good. I tried and tried with lot of available web reference and finally with the following, I got what I desire to have: <?php if(isset($_POST['submit1'])) { $sanfor = $_POST['sanfor']; $fund = $_POST['fund']; if ($sanfor == 'visit' && $fund == 'de'){ header('location:insert_sanction.php'); } if ($sanfor == 'visit' && $fund == 'misc'){ header('location:insert_miscsan.php'); } if ($sanfor == 'meet' && $fund == 'de'){ header('location:insertmeetingsanform.php'); } if ($sanfor == 'meet' && $fund == 'misc'){ header('location:insertmiscmeetingform.php'); } } ?> <form name="sanopt" id="sanopt" action="sanction_option.php" method="POST"> <h3 class="text-white text-left">Sanction for:</h3><br> <input type="radio" name="sanfor" id="visit" value="visit"> VISIT <BR> <input type="radio" name="sanfor" id="meeting" value="meet"> MEETING <br> <br> <br> <h3 class="text-white text-left">Fund:</h3><br> <input type="radio" name="fund" id="defund" value="de"> ENTERTAINMENT <BR> <input type="radio" name="fund" id="miscfund" value="misc"> MISCELLANEOUS <br><br><br> <center><input class ="btn btn-primary" type="submit" name="submit1" value="SUBMIT"/></center> </form> Thank you for all your support and ideas dear friends. |
Lo-Fi Version | Time is now: 19th April 2024 - 06:57 AM |