<select onchange="location.href=this.value">
for($i=0; $i<$num;$i++)
{
$type-> next_record();
$option.="<option value='$PHP_SELF?select=".$type->f(ID)."'>".$type->f(TypeName)."</option>";
}
</select>

解决方案 »

  1.   

    我是用这个在实现
    javascript:location.href=this.options[selectedIndex].value
    但不能定位它的selected
      

  2.   

    test.php?selected=cc
    ------------------------------
    <?
    function selected($value)
    {
    if($_GET['select']==$value)
    echo "selected" ;
    else
    echo "" ;
    }
    ?>
    <form method="get" action="<?basename(__FILE__)?>">
    <select name="select">
    <option <?selected('aa')?>>aa</option>
    <option <?selected('bb')?>>bb</option>
    <option <?selected('cc')?>>cc</option>
    </select>
    <input type="submit">
    </form>
      

  3.   

    <form method="get" action="<?basename(__FILE__)?>" name="frm">
    <select name="select">
    <option <?selected('aa')?>>aa</option>
    <option <?selected('bb')?>>bb</option>
    <option <?selected('cc')?>>cc</option>
    </select>
    <input type="submit"><script language="javascript">
       document.frm.select.value = "aaa";
    </script>
      

  4.   

    上面错了<form method="get" action="<?basename(__FILE__)?>" name="frm">
    <select name="select">
    <option value=1>aa</option>
    <option value=2>bb</option>
    <option value=3>cc</option>
    </select>
    <input type="submit"><script language="javascript">
       document.frm.select.value = "aaa";
    </script>
      

  5.   

    用JS做就好了啊
    <?
    for($i=0; $i<$num;$i++)
    {
    $type-> next_record();
    $option.="<option value='$PHP_SELF?select=".$type->f(ID)."'>".$type->f(TypeName)."</option>";
    }
    echo "<select name='aa' id='aa'>".$option."</select>";
    ?>
    <script language="javascript">
       document.alll.aa.selectedIndex = 1
    </script>
      

  6.   

    <script lanaguage="javascript">
    function selctedme1()
    {
      if(document.queryusergroup.InterestId.value!='')
     { 
    location.href=this.options[selectedIndex].value

      }
    }
    </script><?php
    for($i=0; $i<$num;$i++)
    {
    $type-> next_record();
    $option.="<option value='$PHP_SELF?select=".$type->f(ID)."'>".$type->f(TypeName)."</option>";
    }
    ?>
      <select name=selectpage onchange=selctedme1()><option >--choose--</option><?=$option?></select>