源于生活

标题: form如何将同一个表单的值提交到两个不同的页面 [打印本页]

作者: kevin-ying    时间: 2014-2-15 11:38
标题: form如何将同一个表单的值提交到两个不同的页面
用JS来给ACTION赋值然后再提交
——————————————
  1. <script>
  2. function subform(i)
  3. {
  4. var theform=document.form1;
  5. theform.action=i;
  6. theform.submit();
  7. }
  8. </script>

  9. <form name="form1">
  10. <input name="" type="text" value="1fdsa"/>
  11. <input name="提交" type="button" onClick="subform('11.asp')" id="提交" value="提交" />
  12. <input name="新" type="button" onClick="subform('22.asp')" id="新" value="新" />
  13. <input name="新2" type="button" onClick="subform('33.asp')" id="新2" value="新2" />  
  14. </form>
复制代码





作者: kevin-ying    时间: 2014-2-15 12:23
下面的代码是已测试通过的
  1. <script> function send_2page_f(formname,page1,target1,page2,target2)
  2. {
  3. with(eval("document."+formname))
  4. {
  5. action=page1
  6. target=target1
  7. submit()
  8. action=page2
  9. target=target2
  10. submit()
  11. } } </script> <form name="form">
  12. <input type="button" onclick='send_2page_f("form","01.asp","01","02.asp","02")' value="提交">
  13. </form>
复制代码




_____________________________________________________________________________

我的改写,用图片提交:

  1. <script language="javascript">
  2.          function send_2page_f(formname,page1,target1,page2,target2)
  3. {
  4. with(eval("document."+formname))
  5. {
  6. action=page1
  7. target=target1
  8. submit()
  9. action=page2
  10. target=target2
  11. submit()
  12. } } </script><form name="search" method="post">
  13.         <tr>
  14.         <td height="20" align="center" width="330"><input name=txtitle type=Text id=txtitle size=40 maxlength=50 /></td><td >
  15.         <INPUT type=image onclick='send_2page_f("search","searchnews.asp","01","search.asp","02")' height=20 width=54 style="border:0px;" src="images/2/index_38.gif"></td>
  16.         </tr>
  17.         </form>
复制代码








欢迎光临 源于生活 (http://bbs.vingoo.info/) Powered by Discuz! X3.1