getElementById在IE和FireFox浏览器中的区别

来源:互联网 发布:windows 7破解 编辑:程序博客网 时间:2024/05/22 07:01

JS代码:

function GoToList(){    //var partID=document.getElementById('SelectClassId').selectedOptions[0].value;//此语句在IE中无法正常取值,但在非IE中正常    //以下为通用方法:    var a=document.getElementById("SelectClassId");//从document对象中,获取select标签    var partID=a.options[a.selectedIndex].value;//select标签获取的值其实是一个数组--a.options[]; 然后,选定项的下标是--a.selectedIndex        //document.write(partID);    var Url="SelectPart.asp?Pid="+partID;    window.location.href=Url;} 

HTML代码:

<select id="SelectClassId" name="SelectClassId">    <option value="1">分类一</option>    <option value="2">分类二</option>    <option value="3">分类三</option>    <option value="4">分类四</option>    <option value="5">分类五</option></select><input type="button" id="Sure" name="Sure" value="确认" onclick="GoToList()" /> 



0 0
原创粉丝点击