我在页面中有以下 snipet。我一生都无法弄清楚为什么单击 button1 元素时表单没有提交。我在 IE 中收到一个错误,说这个对象不支持这个属性或方法。我将 document.poform 放在一个警报中,它会向一个表单对象发出警报。我觉得我错过了一些非常明显的东西??

<pre>
<?
    var_dump($_POST);
?>
</pre>
<form action="" method="post" name="poform">
    <input name="test" type="text" />
    <input name="button" type="button" value="button1" onclick="document.poform.submit();" />
    <input name="submit" type="submit" value="button2" />
</form>

最佳答案

由于您有一个名为 <input>submit ,因此 document.poform.submit 就是 <input> ,而不是 submit() 方法。

使用不同的名称。

关于javascript - 为什么 form.submit() 不起作用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6736341/

10-12 12:56
查看更多