setting target page using javascript

In the following example, the form’s action property is set dynamically using javascript. This method can help in setting the target page to which form should submit data on the run time.

<!DOCTYPE html>
    <title>Untitled document</title>
  <meta charset="utf-8" />

    <script language="javascript" type="text/javascript">

        function myfunction(actionvalue)
            var myform = document.getElementById("frm");
            myform.action = actionvalue;
            // document.write(myform.method);
            // myform.reset();



<form id="frm" name="frm" method="post" action="about.html">

    <input id="txtname" name="txtname" type="text" />
    <input id="btn1" name="btn1" type="button" 
           value="Form1Data.html" onclick="myfunction('form1data.html');" />

    <br /><br />

    <input id="btn2" name="btn2" type="button"
           value="Form2Data.html" onclick="myfunction('form2data.html');" />

    <br /><br />

    <input id="btn3" name="btn3" type="reset"
           value="Reset" />





Add a Comment

Your email address will not be published. Required fields are marked *