0

How can i get input in javascript using html forms

23rd Sep 2017, 5:03 AM
taufeeq
taufeeq - avatar
3 Answers
+ 4
Try this: <form name="myform" onsubmit="getName(event)"> <input type="text" name="yourname" /> <input type="submit" /> </form> <script> function getName(e) { e.preventDefault(); alert(myform.yourname.value); } </script>
23rd Sep 2017, 7:48 AM
CalviÕ²
CalviÕ² - avatar
+ 2
Just change alert to document.write
23rd Sep 2017, 12:43 PM
CalviÕ²
CalviÕ² - avatar
0
i want to save that input in a js variable from html form
23rd Sep 2017, 12:29 PM
taufeeq
taufeeq - avatar