根据select1的选项填充select2 提交表单时怎样获取select2的信息
<form name="form1" method="post" action="">
  <select name="select1">
    <option value="0">选择选项</option>
    <option value="1">生活用品</option>
    <option value="2">计算机类</option>
    <option value="3">书籍类</option>
  </select>
  <select name="select2">
  </select>
    <input name="" type="submit" value="提交">
</form><?php
print_r($_POST);
?>

解决方案 »

  1.   

    <script>
    document.getElementsByName('select2').value
     //或则 document.form1.select2.value
    </script>
    如果设置了id
    如:<select name="select2" id="select2">
       </select> 
    则可以写成 document.getElementById('select2').value
      

  2.   

    <select name="select1" id="select1" onchange="document.getElementById('select2').options[0]= new Option(this.options[this.selectedIndex].text,this.options[this.selectedIndex].value)">
         <option value="0"> 选择选项 </option>
         <option value="1"> 生活用品 </option>
         <option value="2"> 计算机类 </option>
         <option value="3"> 书籍类 </option>
       </select>
       <select name="select2" id="select2">
       </select>
         <input name="" type="submit" value="提交">