[Turn] to achieve a form of multiple submissions

Q:
I have three in a form submit button, to achieve different click the button to achieve different operations.
There is no better solution.
In this small section waiting for friends.
Thank you.
______________________________________________________________________________________________
A 1:
then defined at the beginning of the text in the javascript button onClick = "return calc_form ()" to the steering
function print_form ()
  {
   document.form.action = "ID = print_page.php <= $ ID??? > ";
   document.form.target =" _ blank ";
  }
function sub_form ()
  {
   document.form.input_ok.value =. 1;
   document.form.action =" ID = buy_list.php <= $ ID> "??? ;
   document.form.target = "";
  }
function save_form ()
  {

   document.form.input_ok.value=2;
   document.form.action = "buy_list.php?id=<?=$id?>";
   document.form.target="";
  }

______________________________________________________________________________________________
Answer:
The easiest way: write a script for each button
<form the above mentioned id = frm1 name = frm1 Method, = POST Action = "">
<the INPUT the above mentioned id = sendvalue name = sendvalue>
<the INPUT of the type = the Button the above mentioned id = btn1 name = btn1 onclick = "send1 () " value = " submit. 1">
<INPUT type = Button ID = btn1 name = btn1 the onclick = "Send2 ()" value = "Submit 2">
<INPUT type = Button ID = btn1 name = btn1 onclick = "send3 () " value = " submit. 3">
</ form>
<Script>
  function SEND1 () {
     frm1.sendvalue =. 1;
     frm1.submit ();    
  }
  function Send2 () {
     frm1.sendvalue = 2;
     frm1.submit ();
  }
  ...
</script>
______________________________________________________________________________________________
Answer 3:
Switch ($ the Submit) {
  Case "add": 
    echo "choice is to add";
    BREAK;
  Case "delete":
    echo "choice is to delete";
    BREAK;
  Case "Rename":
    echo "selected renaming ";
    BREAK;
}


______________________________________________________________________________________________
A4:

A form more buttons, with a script to achieve the form of points to another method to submit
published in the February 5, 2010 by admin

<coolcode lang="java script"> <form method="post" action="option.php?action=mailsend_out" id="writemail">

<input type="submit" value="发送邮件" onClick="sendmail()" id="sendmaila">
<input type="button" value="存为草稿" onClick="savedraft();" id="saveddd">
<input type="hidden" name="saveD" value="">
<input type="button" onClick="history.back();" value="返回" id="backhistory">

<script>
function savedraft(){
document.getElementById("saveD").value="savedraft";
//alert(document.getElementById("saveD").value);
document.getElementById("writemail").submit();
}
function sendmail(){
document.getElementById('sendmaila').disabled='disabled';
document.getElementById('sendmaila').value='发送中,请等待…..';
document.getElementById('saveddd').disabled='disabled';
document.getElementById('backhistory').disabled='disabled';
document.getElementById('writemail').submit();
}

</script>
</form>

</coolcode>

Where <input type = "hidden" name = "saveD" value = ""> is the key, which is a hidden set of input, pressing a different button assignments to different this hidden value, then option.php? Action = mailsend_out step process as long as the determination of the value it saveD
entry was posted in Category javascript. The fixed link Add to Favorites.

 

______________________________________________________________________________________________
A5:

Generally form only a spooler (e.g., CGI program; the ASP program, etc.) corresponding thereto, to process the data form submission.
        However, in some cases, we can expect according to the user's option, to the different spooler same form.
That is, the form of points to be submitted. For example, we hope to achieve when users send postings, both when sending submit another preview function, you will encounter the above problems. That is, when the user clicks the submit button, we want the form to be submitted to the "Submit" handler; and when the user clicks on the preview button, we want the form to be submitted to the "Preview" handler. So, how to achieve these functions? The following code can be a good solution to this problem.


<form name="form" method="post">
测试表单:<input name="test"><br>
<input type="button" value="提交" onClick=send()>
<input type="button" value="预览" onClick=preview()>
</form>
<script language=javascript>
function send()
{
document.form.action="send.asp"
document.form.submit()
}
function preview()
{
document.form.action="preview.asp"
document.form.submit()
}
</script>

         function send () {document.form.action = " send.asp" document.form.submit ()} function preview () {document.form.action = "preview.asp" document.form.submit ()} About above two examples illustrate:
        1, the entire form, there should be no action or submit a name for the label, otherwise it will generate an error "Object properties, and this method does not support" (but this is no error in firefox). The code of "<input type = '' xxxx '' name = '' action ''>" is not allowed in the form of;
        2, should be present in the form tag name attribute. That is, it should be a name to the form. Statements document.form.action and document.form.submit in the "form" is the name of the form.
        Forms of points used in the program to submit only forum, it also can be used in many cases. Proper use of the form to submit sub-functions can greatly enhance the degree of humanity site.

        Sometimes the debugger there have been such a problem, there was an error "Object does not support this property and method", has been unable to locate it, almost mad, but it was because a button to submit the name.

______________________________________________________________________________________________
A 6:
a text box are two buttons how to submit data
<Script Language = JavaScript>
function ASK () {
document.all.dform.action = "ask.asp";
document.all.dform.submit ();
}
</ script>

<form action="search.jsp" method=get name=dform>
<input type=text>
<input type=submit value="搜索">
<input type=button value="提问" onclick="cancel();">
</form>

 

http://hi.baidu.com/flysnows/item/26311fcdb73a2724e90f2e35

Reproduced in: https: //www.cnblogs.com/kiwi/archive/2012/11/29/2795063.html

Guess you like

Origin blog.csdn.net/weixin_34008805/article/details/94125770