<input type="submit" name="Submit" value="提交" onclick="calc()" />改成
<input type="button" name="Submit" value="提交" onclick="calc()" />试试
<input type="button" name="Submit" value="提交" onclick="calc()" />试试
调试欢乐多
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" language="javascript">
<!--function calc()
{
var x=document.form1.textfield.value;
var y=document.form1.textfield2.value;
var z=parseFloat(x)*parseFloat(y);
document.form1.textfield3.value=z;
}
//-->
</script>
</head><body>
<form id="form1"
<label>1
<input type="text" name="textfield" />
</label>
<p>
<label>2
<input type="text" name="textfield2" />
</label>
</p>
<p>
<label>3
<input type="text" name="textfield3" />
</label>
</p>
<p>
<label>
<input type="button" value="提交" onclick="calc()" />
</label>
</p>
</form>
<p> </p>
</body>
</html>这样就可以拉
submit类型的按钮一般对应的方法是 onsubmit
<input type="submit" name="Submit" value="提交" onsubmit="return calc()" />
执行提交前的数据校验button的话click后执行onclick里的方法.