【发布时间】:2015-07-13 06:04:32
【问题描述】:
我有两个表单,我想同时使用这两个表单。我知道使用 ajax 是可能的。
Form1
<form action="upload.php" method="post">
<label for="url">Enter URL:</label>
<input type="text" name="url" size="35" /><br/>
<label for="filemam">File Name:</label><br/>
<input type="text" name="filenam" size="35" />
<br/> <input type="submit" name="sut" value="Submit" />
</form>
Form2
<form method="post" action="forum2_add_:user-prvar-7890:.xhtml:admin-hash-amp:"> <div id="bb"><br/> <img src="http://scodec.xtgem.com/400px-Warning_icon.svg_.png" width="20" height="20"/> <b><font color="#696969">Avoid All Capital Letter on your thread title, special character like (') is not allowed.**</font></b><br/> <b>Thread Title:</b> <input type="text" name="tema_nazov" value="" maxlength="200"/></div> <div id="bb"><br/><b><font color="#696969"> <img src="http://scodec.xtgem.com/400px-Warning_icon.svg_.png" width="20" height="20"/> Article content should be easy to read, easy to understand,presentation clear in order to attract readers.</font></b><br/><b>Content:</b> <br/> <textarea name="text" rows="5"></textarea>
<input type="hidden" name="d_token" value="" /><input type="submit" name="submit" value="Submit" onclick="conti()" style="margin:2px"/></div></form>
</div></div>
注意:
-
我想将 form1 作为 Javascript 运行
-
我想将 form2 提交按钮作为 onclick 运行。
有人吗?
【问题讨论】:
-
如果您有一个名为“submit”的表单控件,那么您不能调用表单的提交方法(因为 form.submit 现在引用的是控件,而不是方法)。您的标记还有其他问题。
-
MDN 很好地介绍了纯 JS XMLHttpRequest 的基础知识。真的不难,还有很多小库可以帮忙。
标签: javascript html ajax forms