PDA

View Full Version : user dynamic dropdown to link to a page


georgina_barrett_187762
04-11-2011, 04:18 AM
I have set up the dynamic dropdowns successfully. However I now need it to redirect to a particular page dependant on what you select in the child dropdown. At the moment the value of the child dropdown is an ID and when you submit the form it goes to a single page. I want it to go to different pages dependent on what you select in the child dropdown . ie <option value="http://mydomain.com/12.php">12</option> 12 being the ID value from the child dropdown.

I hope I am explaining myself ok. Essentially I need the form to redirect to a page that is selected from the child dropdown (using the ID as the page name) so

<option value="http://mydomain.com/12.php">Link to option 12</option>
<option value="http://mydomain.com/13.php">Link to option 13</option>
<option value="http://mydomain.com/14.php">Link to option 14</option>

Jason Byrnes
04-11-2011, 08:13 AM
the value of the option should be only the ID, you will perform the redirect when the form submits:

<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
header("Location: http://mydomain.com/".((isset($_POST['selectName']))?$_POST['selectName']:"").".php");
}?>


where "selectName" is the name of the select list.