Process the Form action in the save page : Form Post « JSP « Java Tutorial






<HTML>
    <HEAD>
        <TITLE>Using Buttons</TITLE>
    </HEAD>

    <BODY>
        <% 
            //if(request.getParameter("buttonName") != null) {
            if(request.getParameterNames() != null) {
        %>
            You clicked 
            <%= request.getParameter("buttonName") %>
        <%
            }
        %>

        <FORM NAME="form1" METHOD="POST">
            <INPUT TYPE="HIDDEN" NAME="buttonName">
            <INPUT TYPE="BUTTON" VALUE="Button 1" ONCLICK="button1()">
            <INPUT TYPE="BUTTON" VALUE="Button 2" ONCLICK="button2()">
            <INPUT TYPE="BUTTON" VALUE="Button 3" ONCLICK="button3()">
        </FORM>

        <SCRIPT LANGUAGE="JavaScript">
            <!--
            function button1()
            {
                document.form1.buttonName.value = "button 1"
                form1.submit()
            }    
            function button2()
            {
                document.form1.buttonName.value = "button 2"
                form1.submit()
            }    
            function button3()
            {
                document.form1.buttonName.value = "button 3"
                form1.submit()
            }    
            // --> 
        </SCRIPT>
    </BODY>
</HTML>








23.26.Form Post
23.26.1.Get Form Parameter Enumeration
23.26.2.Get Form Parameter By Index
23.26.3.Form Calculator
23.26.4.Process the Form action in the save page
23.26.5.Use multiple forms
23.26.6.Get submit button value