Javascript 为什么这个代码有错误
我能做什么?试试这个Javascript 为什么这个代码有错误,javascript,html,Javascript,Html,我能做什么?试试这个 //this is a part of html code <form> <b>user:</b> <input type="text" name="user" size="25"/> <input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)"/> </form> <script t
//this is a part of html code
<form>
<b>user:</b> <input type="text" name="user" size="25"/>
<input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)"/>
</form>
<script type="text/javascript">
function mehdi(rno){
rno.user.value = 2 * Math.PI ;//this is error line user is unknown
alert(rno);
return rno;
}
</script>
rno.user是一个HTMLInputElement,而不是它的value属性。我复制/粘贴了该代码,它运行时没有错误。下次编辑时,您应该保留原始问题并突出显示更改。这只会让人困惑。一旦你根据其中一个答案编辑了它,你的问题就毫无意义了。羞耻
<form>
<b>user:</b> <input type="text" name="user" size="25"/>
<input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)">
</form>
<script type="text/javascript">
function mehdi(rno)
{
rno.user.value = 2 * Math.PI ;//this is error line user is unknown
alert(rno.user.value);
return rno.user.value;
}
</script>