我正在尝试在此网站http://homepage.ntlworld.com/kayseycarvey/jss3p11.html上遵循本教程指南?
但是,我在这样做时遇到了一些困难。即使我做了完全相同的事情。如果您知道,请指导我。这是我所做的:
<html>
<script>
function GetSelectedItem() {
chosen = ""
len = document.f1.r1.length
for (i = 0; i <len; i++) {
if (document.f1.r1[i].checked) {
chosen = document.f1.r1[i].value
}
}
if (chosen == "") {
alert("No Location Chosen")
}
else {
alert(chosen)
}
}
</script>
<body>
<form name="f1">
<Input type = radio Name = r1 Value = "NE">North East
<Input type = radio Name = r1 Value = "NW">North West
<Input type = radio Name = r1 Value = "SE">South East
<Input type = radio Name = r1 Value = "SW">South West
<Input type = radio Name = r1 Value = "midlands">Midlands
</form>
</body></script>
</html>
附带说明一下,我是否必须对表单执行任何操作才能触发函数 GetSelectedItem ?提前致谢 !