HTML - attributes - action

revision:


Content

"action" attribute : specifies where the formdata is to be sent to the server syntax some examples


"action" attribute : specifies where the formdata is to be sent to the server

top

It can be used in the <form> element.


syntax

top

<form action="URL"></form>

URL is used to specify the URL of the document where the data to be sent after the submission of the form. The possible values of the URL are: 1/absolute URL points to another website link; 2/ relative URL is used to point to a file within a webpage.


some examples

top



After submitting the form, data will sent to the "test.php" page on the server.

codes:
                    <form style="margin-left:5vw;" action="test.php" method="post" id="users">
                        <label for="username">Username:</label>
                        <input type="text" name="username"id="Username"><br>
                        <label for="password">Password: </label>
                        <input type="password" name="password">
                    </form><br>
                    <button style="margin-left:5vw;" onclick="mySubmit()">Submit</button><br>
                    <p class="spec">After Submitting the form-data will sent to the "test.php" page on the server.</p>
                
First name:
Last name:

codes:
                    <form style="margin-left:5vw;" action="/action_first_page.php" method="get">
                        First name: <input type="text" name="fname"><br>
                        Last name: <input type="text" name="lname"><br>
                        <button type="submit">Submit</button><br>
                        <button type="submit" formaction="/action_second_page.php">Submit to another page</button>