请问 <form action="search.php" method="post"> 
<select name="cname" size=10.
<option>Cappuccino
<option>frappuccino coffee
然后在search.php得到选中元素的值怎么得到阿

解决方案 »

  1.   

    <html>
    <body>
    <form action="search.php" method="post"> 
    <select name="cname" >
    <option>Cappuccino
    <option>frappuccino coffee </select>
    <input type="submit" name="sub" value="submit">
    </form>
    <?php
    $ab=$_REQUEST["cname"];
    echo $ab;
    ?>
    </body>
    </html>
      

  2.   

    <html>
    <body>
    <form action="61.php" method="post"> 
    <select name="cname" >
    <option>Cappuccino
    <option>frappuccino coffee </select>
    <input type="submit" name="sub" value="submit">
    </form>
    <?php
    $ab=$_REQUEST["cname"];
    echo $ab;
    ?>
    </body>
    </html>
      

  3.   

    如果刷新本页面的话,那select 中的内容始终是初始值,怎么个改法?
      

  4.   

    我都是这么用的。if(isset($_POST("cname")))
    {
       $value1=$_POST("cname");//获取内容
    }
      

  5.   

    这好像只是赋值,我是说如果刷新本页面的话,那select 中的内容始终是初值,我想让他变成我选中的值?
      

  6.   

    你要的是不是这样的效果?
    <style>   
                  .userData   {behavior:url(#default#userdata);}   
      </style>   
      <select   id="select1"     class="userData">   
      <option>option1</option>   
      <option>option2</option>   
      <option>option3</option>   
      <option>option4</option>   
      </select>   
      <script>   
      var   obj=document.all.select1;   
      obj.attachEvent('onchange',saveSelectedIndex)   
      function   saveSelectedIndex(){   
      obj.setAttribute("sSelectValue",obj.selectedIndex);   
      obj.save("oSltIndex");   
      }   
      window.attachEvent('onload',loadSelectedIndex)   
      function   loadSelectedIndex(){   
      obj.load("oSltIndex");   
      obj.selectedIndex=obj.getAttribute("sSelectValue");   
      }   
      </script>
      

  7.   

    象7楼一样, 在select里加上 onchange函数 。将所选择的值赋给select。<select name="cname" size=10 onchange="function1()">
      

  8.   

    LS的是什么意思?function1()是什么?
      

  9.   

    大家去我的帖子回下吧,我是同样的问题,这样我也好给分呢
    顺便问下zmouki你的script怎么触发的,直接写在下面就可以了吗,还是要有什么事件来触发呢
      

  10.   

    你新建一个.html文件,自己跑一下看看结果就应该能明白了.
    <html>
    <body>
    <style>  
                  .userData  {behavior:url(#default#userdata);}  
      </style>  
      <select  id="select1"    class="userData">  
      <option>option1 </option>  
      <option>option2 </option>  
      <option>option3 </option>  
      <option>option4 </option>  
      </select>  
      <script>  
      var  obj=document.all.select1;  
      obj.attachEvent('onchange',saveSelectedIndex)  
      function  saveSelectedIndex(){  
      obj.setAttribute("sSelectValue",obj.selectedIndex);  
      obj.save("oSltIndex");  
      }  
      window.attachEvent('onload',loadSelectedIndex)  
      function  loadSelectedIndex(){  
      obj.load("oSltIndex");  
      obj.selectedIndex=obj.getAttribute("sSelectValue");  
      }  
      </script>
      </body>
      </html>
      

  11.   

    用POST,GET,_REQUEST都可以得到的.只是你要给SELECT写真VALUE值.看你的SELECT好像没有写VALUE值