javascript - Java Script Mathmatic Equation -
my javascript code isn't working because nothing's showing when click button. know solution? tried taking out code , formatting button alert(...)
, worked, i'm stuck on whats going on math equations. i'm positive didn't miss bracket or punctuation though. feedback , help.
<!doctype html> <html> <head> <title>project</title> <style type="text"/css> .inbox { width=30px; text-align: right; border: 2px solid black; } .align { text-align: right } </style> <script type="text/javascript"> function compute() { var = form1.inputa.value; = parsefloat(a); var b = form1.inputb.value; b = parsefloat(b); var c = form1.inputc.value; c = parsefloat(c); var e = * 5.49; form1.suma.value = e.tofixed(2); } function pageinit() { form1.inputa.focus(); } </script> </head> <body onload="pageinit();"> <form id="form1"> <table border="2" > <tr> <th colspan="4">sample order form</th> </tr> <tr> <th>quantity</th> <th>item</th> <th>unit price</th> <th>totals</th> </tr> <tr> <th> <input tabindex="1" class="inbox" type="text" id="inputa" /> </th> <th>apples</th> <td>$5.49</td> <th> <input class="inbox" type="text" id="suma" readonly="readonly" /> </th> </tr> <tr> <th> <input tabindex="4" type="button" value="compute" onclick="compute();" /> </th> </tr> </table> </form> </body> </html>
try this
<!doctype html> <html> <head> <title>project</title> <style> .inbox { width =30px; text-align: right; border: 2px solid black; } .align { text-align: right; } </style> <script type="text/javascript"> function compute() { var = document.getelementbyid("inputa").value; var e = * 5.49; document.getelementbyid("suma").value = e.tofixed(2); } function pageinit() { document.getelementbyid("inputa").focus(); } </script> </head> <body onload="pageinit();"> <form id="form1"> <table border="2"> <tr> <th colspan="4">sample order form</th> </tr> <tr> <th>quantity</th> <th>item</th> <th>unit price</th> <th>totals</th> </tr> <tr> <th> <input tabindex="1" class="inbox" type="text" id="inputa" /> </th> <th>apples</th> <td>$5.49</td> <th> <input class="inbox" type="text" id="suma" readonly="readonly" /> </th> </tr> <tr> <th> <input tabindex="4" type="button" value="compute" onclick="compute();" /> </th> </tr> </table> </form> </body> </html>
javascript math button
No comments:
Post a Comment