0

How can i get input in javascript using html forms

23rd Sep 2017, 5:03 AM
taufeeq
taufeeq - avatar
3 Respuestas
+ 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