Help - Search - Members - Calendar
Full Version: NAVIGATION TO DIFFERENT PAGES BASED ON MULTIPLE RADIO BUTTON OPTION SELECTION
HTMLHelp Forums > Programming > Client-side Scripting
shankar from vizag
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
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
QUOTE(Christian J @ May 24 2019, 10:52 PM) *

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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sanfor" id="visit" value="visit"> VISIT
<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sanfor" id="meeting" value="meet"> MEETING
<br>
<br>
<br>
<h3 class="text-white text-left">Fund:</h3><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="fund" id="defund" value="de"> ENTERTAINMENT
<BR>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.