请各位高手帮我看下:下面的Java函数错在哪里

来源:百度知道 编辑:UC知道 时间:2024/05/13 05:00:01
新手上路,请各位帮忙小弟一下:
<form name="form1" method="post" action="">
<label>
<input type="text" name="n1" id="n1">
</label>
<p>
<label>
<input type="text" name="n2" id="n2">
</label>
</p>
<p>
<label>
<input type="button" name="button" id="button" value="+" onclick="fun(a)">
</label>
<label>
<input type="button" name="button2" id="button2" value="-" onclick="fun(a)">
</label>
<label>
<input type="button" name="button3" id="button3" value="*" onclick="fun(a)">
</label>
<label></l

<input type="button" name="button" id="button" value="+" onclick="fun(1)">

<input type="button" name="button" id="button" value="+" onclick="fun(2)">

<input type="button" name="button" id="button" value="+" onclick="fun(3)">

<input type="button" name="button" id="button" value="+" onclick="fun(4)">

把上面4句话改一下就可以了。。

传递的参数值是 1 2 3 4

祝你好运!!

有很多很多错误
首选,这不是java函数错在哪里呢,而是javascript函数错在哪里了;
其次,你定义了fun(a)函数,可是每个按钮后面得onclick=fun(a)这里不应该是a,而应该分别为:‘+’,'-','*','/'。
最后,似乎form1.n2.value应该加上document.form1.n2.value.两个似乎都该加上document.
一个简单的程序,错误都如此之多。
罕见之事