javascript - New to web developing, got an error (jsfiddle) -


i absolute begginer web developing , want chance calculator in online tool: jsfiddle. got error:"shell form not validate" , strange errors after. here html code:

<body>     <form method="post">the chance of succes:         <input type="number" name="chance">         <br>how many tries:         <input type="number" name="tries">         <br>         <input type="submit" value="calculate!">         <br>     </form> </body> 

and javascript code is:

function calculate(chance, tries) {     console.log(chance / tries * 100); } 

as said, new please try explain step step.

you have few problems. 1 form trying submit itself. calculate function never called.

your parameters function never called either. let's change inputs have id instead of name. example:

<input type="number" id="chance"> 

this makes easier value input when clicking button. i've made input button instead of submit, make sure form data isn't getting sent anywhere.

<input type="button" onclick="return calculate(getelementbyid('chance').value, getelementbyid('tries').value)" value="calculate!"> 

here jsfiddle possible solution you. http://jsfiddle.net/0dmkxcab/


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -