I can't figure out why my form isn't working. Granted, it's been a while since I've done any JavaScript...
Anyway, here's what I have:
Also, if anyone feels like helping me code it to round the Win and Loss % to a whole number (like 19.4 to 19) and to format Expected Profit, Loss, and Value as money (two places after the decimal point), that'd be great as well. I forget how to do that.HTML Code:<html> <head> <title>Expected Value Calculator</title> <script type="text/javascript"> function solvepy(form) { a = parseInt(form.a.value); b = parseInt(form.b.value); c = parseInt(form.c.value); d = parseInt(form.d.value); form.e.value = (c+d); e = parseInt(form.e.value); form.f.value = (a*e) f = parseInt(form.f.value); form.g.value = (b*d); g = parseInt(form.g.value); form.h.value = (f-g); h = parseInt(form.h.value); } </script> <script type="text/javascript"> function clearform() { document.ev.a.value= " "; document.ev.b.value= " "; document.ev.c.value= " "; document.ev.d.value= " "; document.ev.e.value= " "; document.ev.f.value= " "; document.ev.g.value= " "; document.ev.h.value= " "; } </script> </head> <body> <p>For Win and Lose %, please round to the nearest whole number. For instance, if your chance to win is 19.4% and your chance to lose is 80.6, round them to 19 and 81, respectively.</p> <form name="form"> <input type=text name=a size=4> - Win %<br> <input type=text name=b size=4> - Lose %<br> <input type=text name=c size=4> - Pot Size before Opponent Bets<br> <input type=text name=d size=4> - Opponent's bet<br> <input type=text name=e size=4 readOnly=true> - Total Pot Value<br> <input type=text name=f size=4 readOnly=true> - Expected Profit<br> <input type=text name=g size=4 readOnly=true> - Expected Loss<br> <input type=text name=h size=4 readOnly=true> - Expected Value <br> <input type="button" value ="Calculate" name="Submit" onClick="solvepy(this.form)"><br> <input type="button" name="Submit2" value="Clear" onClick="clearform()"> </form> </body> </html>



Reply With Quote

Bookmarks