View Single Post
  #9 (permalink)  
Old 12-03-09, 04:42 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
Another option:

PHP Code:

/* Default page - either the same page, or an error page */

$sPage='default.php';
/* Ensure both ids are set.  It's okay if they are set but empty */
if (isset($_POST['id1']) && isset($_POST['id2']))
{
  
$aPageMap=array('101'=>'page1.php',
                                
'102'=>'page2.php',
                                
'103'=>'page3.php',
                                
'201'=>'page4.php',
                                
'202'=>'page5.php',
                                
'203'=>'page6.php',
                                
'301'=>'page7.php',
                                
'302'=>'page8.php',
                                
'303'=>'page9.php');
  
/* Create the array index - it's okay if it is not valid */
  
$iPageIndex=$_POST['id1'].$_POST['id2'];
  
/* Check to see if the array index is valid, if so, use it */
  
if (array_key_exists($iPageIndex,$aPageMap))
    
$sPage=$aPageMap[$iPageIndex];
}
/* Go to the page */
header('location: '.$sPage); 
This could also be done in javascript, like so:

HTML Code:
<script type="text/javascript">
function go()
{
  var o1=document.getElementById('id1');
  var o2=document.getElementById('id2');
  var i=0;l=o1.options.length;
  for (i=0;i<l;i++)
  if (o1.options[i].selected)
  {
    m=o2.options.length;
    for (j=0;j<m;j++)
      if (o2.options[j].selected)
        location.href=o1.options[i].value+o2.options[j].value;
  }
}
</script>

<!-- Be sure to give the <select> tags ids -->
<select name="id1" id="id1">

...

<select name="id2" id="id2">

...

<button onclick="go()">Go</button>
Not tested.
Reply With Quote