[英]Post Single Form Value To Self With On Click Href
I have a basic form. 我有一个基本表格。 All the elements are text fields.
所有元素都是文本字段。
There is a regular submit button at the end that posts the form to another page. 最后有一个常规的提交按钮,可将表单发布到另一个页面。
The problem is I have one text field within the form, that I want to be able to post to the form and reload the page after running through a script. 问题是我在表单中有一个文本字段,我希望能够在运行脚本后将其发布到表单并重新加载页面。
Sample code: 样例代码:
<?php
if (isset("var_needed"){
... Do all this....
}else;
?>
<form id="form" action="post_to_next_page.php" >
<input name="var1" type="text" id="var1"/>
<input name="var2" type="text" id="var2"/>
<input name="var3" type="text" id="var3"/>
<input name="var_needed" type="text" id="var_needed" />
<a href="#" onclick="...?...."><img src="../image/_apply_code_button.jpg" width="132" height="28" />
<input name="var4" type="text" id="var4"/>
<input name="var5" type="text" id="var5"/>
<input type="submit" name="submit" id="submit" value="Submit" />
I figure I can do this with some sort of JavaScript that gets executed with the onclick
handler of an image within the form. 我想我可以使用某种JavaScript来做到这一点,这些JavaScript可以通过表单中图像的
onclick
处理程序执行。 Any help would be appreciated. 任何帮助,将不胜感激。
<a href="#" onclick="onclick="document.getElementById("form").submit(); return false;">
Are you looking for something like this? 您是否正在寻找这样的东西?
<?php
if (isset($_GET['somevar'])){
... Do all this....
}else;
?>
<form id="form" action="post_to_next_page.php" >
<input name="var1" type="text" id="var1"/>
<input name="var2" type="text" id="var2"/>
<input name="var3" type="text" id="var3"/>
<input name="var_needed" type="text" id="var_needed" />
<a href="?somevar=yes"><img src="../image/_apply_code_button.jpg" width="132" height="28" />
<input name="var4" type="text" id="var4"/>
<input name="var5" type="text" id="var5"/>
<input type="submit" name="submit" id="submit" value="Submit" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.