通过单击Href将单个表单值发布到自身


Post Single Form Value To Self With On Click Href

我有一个基本的表单。所有元素都是文本字段。

末尾有一个常规提交按钮,用于将表单发布到另一个页面。

问题是我在表单中有一个文本字段,我希望能够在运行完脚本后将其发布到表单并重新加载页面。

样本代码:

<?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" />

我想我可以用某种JavaScript来实现这一点,这种JavaScript是用表单中图像的onclick处理程序来执行的。如果有任何帮助,我将不胜感激。

<a href="#" onclick="onclick="document.getElementById("form").submit(); return false;">

你在找这样的东西吗?

<?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" />