javascript this 的问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 06:58:19
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>

<script language="javascript">
function processData(form)
{
for (var i=0;i<form.Beatles.length;i++)
{
if(form.Beatles[i].checked)
{
break;
}
}

var beatle=form.Beatles[i].value
// var song=form.song.value
alert("chenking whether features"+beatle+"`````");
}

</script>
</HEAD>
<BODY >
<form onsubmit="return false">
<input type="radio" name="beatles" checked value="1"> 1
<input type="radio" name="beatles">2
<input type="radio" name="beatles">3
<input type="radio" name=&qu

form.Beatles[i] 改为 form.beatles[i], 你的js代码中有3个地方要改。

this的意思是指对象本身。在这里
<input type="button" name="process" value="提交" onClick="processData(this.form)">
this就是指这个button。

你想实现什么功能