Equal_ 2015-04-11 03:38 采纳率: 21.1%
浏览 11791

select中option的selected属性的动态指定!!

我现在有个select标签,下面有option选项,现在选择后要固定住,等于说提交数据后还是选中的选项。因为涉及到后面的一个分页展示,所以这个值要固定住。

 function mySel(obj){
        //alert(obj.selectedIndex);
        //obj.selected="selected";
        //obj.setAttribute("selected",true);
        var index=obj.selectedIndex;
        var ops=document.getElementById("mySelect");
        for(var i=0;i<ops.options.length;i++){
            if(ops.options[i].selectedIndex==index){
                //ops.options[i].selected="selected";
                ops.options[i].setAttribute("selected","true");
                break;
            }
        }

    }
这是我的代码,用了两种方法,但是每次提交后又变了!!等于这个selected属性没有设置到option上,知道的告诉我为什么?????????????????????????
  • 写回答

2条回答 默认 最新

报告相同问题?

悬赏问题

  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统