Input commit behavior description for the type of submit of the same name
This situation,
<input type= "Submit" Name= "ACTION" value= "Apply"/>
<input type= "Submit" Name= "ACTION" value= "Cancel"/>
It can be used as a button for submitting content, which is sent to the parameters of the server segment, corresponding to the button being clicked activated.
This means multiple names with the same name, and only one commit can be activated at a time.
For example, if you click Apply, the action=apply will be routed to the server side. So that the server can judge the same data submitted,
What do I need to do, modify it, or delete it?
Code
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>phpstudy Probe </title>
<meta http-equiv= "x-ua-compatible" content= "Ie=emulateie7"/>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<body>
<form method= "POST" >
<textarea>
<?php
echo "if_action=". $_post[' if_action '];
echo "Data=". $_post[' data ';
?>
</textarea>
<input type= "text" name= "data" value= "Data"/>
<input type= "Submit" Name= "If_action" value= "Apply"/>
<input type= "Submit" Name= "If_action" value= "Cancel"/>
</form>
</body>
Standard interpretation
Https://www.w3.org/TR/html4/interact/forms.html#current-value
See the following paragraph (on the definition of successful control in form form), this sentence:
If a form contains more than one submit button, only the activated submit button is successful.
All the commit buttons, only the button that is activated, is successful, that can be submitted to the server side.
Paragraph:
17.13.2 Successful controls
A Successful control is ' valid ' for submission. Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must has a control name.
However:
- Controls that is disabled cannot be successful.
- If a form contains more than one submit button, only the activated submit button is successful.
- All ' on ' checkboxes may successful.
- For radio buttons so share the same value of the name attribute, only the ' on ' radio button may be successful.
- For menus, the control name was provided by a SELECT element and values was provided by OPTION elements. Selected options may successful. When no options was selected, the control is not successful and neither the name or any values was submitted to the serve R when the form is submitted.
- The current value of a file select is a list of one or more file names. Upon submission of the form, the contents of each file is submitted with the rest of the form data. The file contents is packaged according to the form's content type.
- The current value of a object control is determined by the object ' s implementation.
Why can't input of type button be submitted? Describe
If there is a button of type buttons that exist with the form, then the form is committed and its submitted parameters do not exist for this button's name and value.
The following code: Pushbutton does not exist in the requested data.
<form id= "FileUpload" name= "FileUpload" method= "post" action= "/index.php" >
<input type= "File" Name= "testfile" multiple= "multiple" ></br>
<input type= "text" name= "TextInput" value= "Textinputvalue" ></br>
<input type= "button" Name= "Pushbutton" value= "pushbutton" >
<input type= "Submit" name= "submit" value= "Upload" ></br>
</form>
Code
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<script src= "./jquery.js" ></script>
<link rel= "stylesheet" href= "./test.css"/>
<body>
<style>
</style>
<form id= "FileUpload" name= "FileUpload" method= "post" action= "/index.php" >
<input type= "File" Name= "testfile" multiple= "multiple" ></br>
<input type= "text" name= "TextInput" value= "Textinputvalue" ></br>
<input type= "button" Name= "Pushbutton" value= "pushbutton" >
<input type= "Submit" name= "submit" value= "Upload" ></br>
</form>
<script>
document.write ("enctype=" +document.getelementbyid ("FileUpload"). GetAttribute ("Enctype"). toLowerCase ());
</script>
</body>
Standard analysis
Https://www.w3.org/TR/html401/interact/forms.html#buttons
The standard explanation of the button is clear, including three types:
1, the type of submission (for submitting the form data, the user click the Submit button, or the cursor form within the keyboard to click the Enter keyboard-IE implementation is the first submit button submission is triggered)
2. Reset the type (reset button-without interacting with the background, you can put the default value of the page control, realistic, that is, the value of HTML value attribute. )
3, push the type (push button-do not hold the commit and reset, need to bind JS processing events, such as the validation of the form parameters after the successful submission of form)
Given its type role, it does not necessarily have to be submitted, and the reset button is similar.
Buttons
Authors may create three types of buttons:
Authors Create buttons with the BUTTON element or the INPUT element. Consult the definitions of these elements for details about specifying different button types.
Note. Authors should note that the BUTTON element offers richer rendering capabilities than the INPUT element.
HTML button as form form element submit attribute two---parameter HTML Test standard analysis