javascript - Using query URL in the form -
i practicing on how query url. not expected output. here code:
form 1:
<html> <head> <title>save value</title> </head> <body> <form action="display.html" method="get"> <label> first name: <input name="name" size="20" maxlength="25" type="text" id="name" /> </label> <input type="submit" value="submit" /> </form> </body> </html>
form 2:
<html> <head> <title>display</title> <script type="text/javascript"> <script type="text/javascript"> function queryvar(variable) { var query = location.search.substring(1); var vars = query.split("&"); var i; (i = 0; < vars.lenght; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return(false); } </script> </head> <body> <form action="#"> <label> first name: <input name="name" size="20" maxlength="25" type="text" id="name" readonly="readonly" /> </label> <script type="text/javascript"> var firstname = document.getelementbyid("name").value; firstname = location.search.substring(1); </script> </form> </body> </html>
so when clicked submit button go form 2 , display value typed in form 1.
thank help!
here's solution wanted do.
form 1
<html> <head> <title>save value</title> </head> <body> <form action="display.html" method="get"> <label> first name: <input name="name" size="20" maxlength="25" type="text" id="name" /> </label> <input type="submit" value="submit" /> </form> </body> </html>
form 2
<html> <head> <title>display</title> <script type="text/javascript"> function queryvar(variable) { var query = location.search.substring(1); var vars = query.split("&"); var i; (i = 0; < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return(false); } </script> </head> <body> <form action="#"> <label> first name: <input name="name" size="20" maxlength="25" type="text" id="name" readonly="readonly" /> </label> <script type="text/javascript"> document.getelementbyid("name").value = queryvar("name"); </script> </form> </body> </html>
Comments
Post a Comment