Dan*_*ron 0 html javascript forms
我目前正在为我的单一课程学习JavaScript,并且由于某种原因我的功能没有被调用.我想明白为什么这不起作用.
简要描述;简介
有两种形式,一种是提交按钮,onSubmit字段调用document.write()(这是有效的),然后调用我自己的函数submit().如果我submit()改为document.write()然后我收到两个输出,所以应该没有读取为什么submit不被调用?
第二种形式有一个文本框,理想情况下,当按下按钮时,我想让它消失,但我主要想了解为什么submit不调用.
<html charset="utf-8">
<head>
<title>Game</title>
</head>
<body>
<form method="get" name="form1" action="game.php" onSubmit="document.write('Hello');submit();">
<input type="submit" value="submit" name="button" />
</form>
<form id="form2" name="form2">
<input name="letter" type="text" />
</form>
<script>
function submit() {
alert("HELLO");
document.getElementById('form2').visibility='hidden';
document.write("Hello");
}
</script>
</body>
Run Code Online (Sandbox Code Playgroud)
我已经尝试在函数上方的函数中,在函数下方插入脚本,但似乎没有任何工作.
希望有人可以帮忙,谢谢
submit是保留的关键字.更改为任何其他名称,它应该工作.请找到相同的JSFiddle
https://jsfiddle.net/pc9rL2ey/
function submita() {
alert("HELLO");
document.getElementById('form2').visibility='hidden';
document.write("Hello");
}
<form method="get" name="form1" action="game.php" onSubmit="submita();document.write('Hello');">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1182 次 |
| 最近记录: |