<form action="three.php" method="post" name="form1" id="form1">
<span>
<select onchange="xx(this)" id='select' name='select'>
<option value="0">所有定单</option>
<option value="1" >有效定单</option>
<option value="2" >已经取消的定单</option>
<option value="3" >三个月前的定单</option>
<option value="4" >近三个月的定单</option>
</select>
我这边本页面刷新 想保存里面的option的值 怎么做呢

解决方案 »

  1.   

    <option value="3" selected>三个月前的定单</option>
    如果是提交后返回(例如填错信息重新填写),把对应值添加属性
    如果是未提交客户端刷新,在onchange里面写入cookies,页面载入时js读取这个cookie再改变对应的option
    代码自己写吧,没写js多年了
      

  2.   

    我是一个form表单 用 js事件提交的 提交到本页面 因为刷新了 option会变回原来的样子  我想保存上一次option的值
      

  3.   

    <form action="three.php" method="post" name="form1" id="form1">
    <span>
    <select onchange="xx(this)" id='select' name='select'>
    <option value="0"<?php if($_POST['select']=='0') echo 'selected';?>>所有定单</option>
    <option value="1" <?php if($_POST['select']=='1') echo 'selected';?>>有效定单</option>
    <option value="2" <?php if($_POST['select']=='2') echo 'selected';?>>已经取消的定单</option>
    <option value="3" <?php if($_POST['select']=='3') echo 'selected';?> >三个月前的定单</option>
    <option value="4" <?php if($_POST['select']=='4') echo 'selected';?>>近三个月的定单</option>
    </select>这种是可以,但是麻烦,你这种情况用ajax提交最好。
      

  4.   


    最好是ajax提交,这样本页面根本不刷新,option选项也就不会变如果是表单提交,就让提交页操作完成后跳转回来的时候把提交的option值转过来(前提是你要在表单页判断是否存在提交页的传值,有就让option值的项selected,没有的话就是首次进表单页,option默认选中)
      

  5.   

    <option value="0"<?php if(isset($_POST['select']) && $_POST['select']=='0') echo 'selected';?>>所有定单</option>
    <option value="1" <?php if(isset($_POST['select']) && $_POST['select']=='1') echo 'selected';?>>有效定单</option>
    <option value="2" <?php if(isset($_POST['select']) && $_POST['select']=='2') echo 'selected';?>>已经取消的定单</option>
    <option value="3" <?php if(isset($_POST['select']) && $_POST['select']=='3') echo 'selected';?> >三个月前的定单</option>
    <option value="4" <?php if(isset($_POST['select']) && $_POST['select']=='4') echo 'selected';?>>近三个月的定单</option>