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
Post a Comment