Tuesday, 2 May 2017

how to get values from a form and put them into global variables

for example
this is our form

 <form action="test1" method="GET" name="frm">
      First name: <input type="text" name="fname"><br>
      Last name: <input type="text" name="lname"><br>
      <input type="submit" value="Submit" >
  </form>

and here I want to put the content of the values from the form and put them into global variables
I've tried this code. But it doesn't display the content of "a"

 <script>
    var a=document.frm.lname.value;
     console.log(a);
 </script>



via Maki

No comments:

Post a Comment