Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
html表单提交按钮_Html_Forms - Fatal编程技术网

html表单提交按钮

html表单提交按钮,html,forms,Html,Forms,我有一个表单,当表单通过浏览器加载时,我希望它自动提交数据。我遇到的问题是,我编写了一个php脚本,可以在测试表单上提交它。我的问题是,我试图将数据提交到名为“提交”按钮的服务器 这是我正在使用的示例表单 <html> <head> </head> <form action="http://www.example.com/post.php" method="post"> <input type="text" name="input1" v

我有一个表单,当表单通过浏览器加载时,我希望它自动提交数据。我遇到的问题是,我编写了一个php脚本,可以在测试表单上提交它。我的问题是,我试图将数据提交到名为“提交”按钮的服务器

这是我正在使用的示例表单

<html>
<head>
</head>
<form  action="http://www.example.com/post.php"  method="post">
<input type="text" name="input1" value="test1"  />
<input type="text" name="input2" value="test2"  />
</form>
<script type="text/javascript">
document.forms[0].action="submit"
</script>
</body>
</html>

document.forms[0]。action=“提交”
在另一台服务器上创建表单的人将其命名为submit。在他们修好之前,有没有其他的办法

下面是persons表单的一个示例

<html>
<head>
</head>
<form  action="http://www.example.com/post.php"  method="post">
<input type="text" name="input1" value="test1"  />
<input type="text" name="input2" value="test2"  />
<input type="submit" name="submit" class="submit" value="Send Data" />
</form>
</body>
</html>


谢谢

您想提交表格吗?然后只需使用其
submit()
方法:

document.forms[0].submit();
如果服务器希望发布
submit
,即单击按钮,则只需触发按钮的
click()
事件。由于您无法使用其名称访问它,因此我将使用jQuery:

$('input[name="submit"]').click();
而不是:

<html>
<head>
</head>
<form  action="http://www.example.com/post.php"  method="post">
<input type="text" name="input1" value="test1"  />
<input type="text" name="input2" value="test2"  />
</form>
<script type="text/javascript">
document.forms[0].action="submit"
</script>
</body>
</html>

document.forms[0]。action=“提交”
试试这个:

<html>
<head>
</head>
<form name="MyForm" action="http://www.example.com/post.php"  method="post">
<input type="text" name="input1" value="test1"  />
<input type="text" name="input2" value="test2"  />
</form>
<script type="text/javascript">
document.MyForm.submit();
</script>
</body>
</html>

document.MyForm.submit();
如果我正确理解了你的问题

具有name=“submit”的输入元素 和type=“submit”是不同的东西


因此,您也可以轻松创建相同的行为

它将尝试提交数据,但无法识别服务器端的任何内容,就像没有提交任何内容一样。这是一个相当本地化的问题。一般来说,在StackOverflow上,问题的措辞最好能够适用于整个开发人员社区,而不仅仅是您遇到的特定问题。