我试图将单选按钮的值发送给javascript函数。最终,函数会做更多的事情,但我的测试已经到了死胡同,因为我一直得到未定义的返回值。以下是我有:在javascript函数中产生未定义值的单选按钮
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
<SCRIPT TYPE="text/javascript">
<!--
function jobWindow(){
var target;
for(i = 0; i < document.jobView.sales.length; i++){
if(document.jobView.sales[i].checked == true)
target = document.jobView.sales[i].value;
break;
}
alert("val = " + target);
//var load = window.open('target','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
}
// -->
</script>
</head>
<body>
<form name="jobView">
<input name ="sales" value="all" type="radio" />All
<input name="sales" value="darell" type="radio" />Darell
<input name="sales" value="kevin" type="radio" />Kevin
<input name="sales" value="brad" type="radio" />Brad
<input name="sales" value="chongo" type="radio" />Chongo
<input type="button" value="View Records" onclick="jobWindow()"/>
<input type="button" value="View Calendar" />
</form>
</body>
</html>
我添加了缺少的大括号,它工作。谢谢你的收获 – shinjuo 2010-09-17 21:34:51