<% for i=1 to anwsa%>
jsxxao<%=i%>=window.self.document.answer.num1<%=i%>A.options(window.self.document.answer.num1<%=i%>A.selectedIndex).value+":"+window.self.document.answer.num1<%=i%>B.options(window.self.document.answer.num1<%=i%>B.selectedIndex).value+":"+window.self.document.all.num1<%=i%>C.value+"<br/>"
iSumA=iSumA+jsxxao<%=i%>;
<%next %>
非常感谢!
anwsa 是从数据库里调出来的是一个数值
这不是纯的js,而是类似asp的代码,你可以直接用html的select控件代替。
因为题 数量要从数据库里调出来,所以用 for这样写的,我是个新手,能不能详细点说说怎么改成别的写法,兼容能好些。谢谢!
options是数组,要改为[],不是(),()只有ie支持,还有不要用document.all,不是所有浏览器都支持,用document.getElementById
而且你的answer是表单还是什么。。看关系应该是dom对象的id,也要用document.getElementById,window.self不需要了,多次一举
jsxxao<%=i%>=document.getElementById('num1<%=i%>A').options[window.self.document.answer.num1<%=i%>A.selectedIndex].value+":"+document.getElementById('num1<%=i%>B').options[document.getElementById('num1<%=i%>B').selectedIndex].value+":"+document.getElementById('num1<%=i%>C').value+"<br/>"
iSumA=iSumA+jsxxao<%=i%>;
楼上说的对,谢谢!今天早上参照例子,解决了,和你说的一样!佩服!!
<script>
function displayResult()
{
var x=document.getElementById("mySelect").selectedIndex;
var y=document.getElementById("mySelect").options;
alert("Index: " + y[x].index + " is " + y[x].text);
}
</script>