html - JavaScript: Form onSubmit not calling function -


i learning javascript uni course , function not being called reason. want understand why not working.

brief description

there 2 forms, 1 has submit button, onsubmit field calling document.write() (this works), calling own function submit(). if change submit() document.write() receive 2 outputs, there should no reads why submit not called?

the second form has single textbox in it, ideally want make disappear when button pressed, want understand why submit not called.

<html charset="utf-8"> <head>     <title>game</title> </head> <body>     <form method="get" name="form1" action="game.php" onsubmit="document.write('hello');submit();">         <input type="submit" value="submit" name="button" />     </form>      <form id="form2" name="form2">         <input name="letter" type="text" />     </form>     <script>         function submit() {             alert("hello");             document.getelementbyid('form2').visibility='hidden';             document.write("hello");         }     </script> </body> 

i have tried inserting script in header, above function, below function, nothing seems work.

hope can help, thanks

submit reserved keyword. change other name , should work. please find jsfiddle of same

https://jsfiddle.net/pc9rl2ey/

        function submita() {             alert("hello");             document.getelementbyid('form2').visibility='hidden';             document.write("hello");         }   <form method="get" name="form1" action="game.php" onsubmit="submita();document.write('hello');"> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -