Skipjackrick Posted February 11, 2008 Share Posted February 11, 2008 I am new to javascript so forgive me. Although, it seems very straightforward and logical and I can't figure out why this simple calculation is not working. I want the points field to be filled when I choose a species and place a quantity. For some reason nothing happens when I fill the too other form entities with values. <html> <head> <title>Kayak Wars Submission Form</title> <script type="text/javascript"> function calc_points() { var species1 = document.getElementById("species").value; var quantity2 = document.getElemendById("quantity").value; var total_points = (species1 * quantity2); document.getElementById("points").value = total_points; } </script> </head> <body> <form id="form1" name="form1" method="POST" action=""> <input type="hidden" name="submit_id" value="NULL"> <select name="species" id="species"> <option value="0">Select Species</option> <option value="1">Red Drum</option> <option value="2">Trout</option> <option value="3">Snook</option> <option value="4">Shark</option> <option value="5">Black Drum</option> <option value="6">Snapper</option> <option value="7">King Mackerel</option> <option value="8">Grouper</option> <option value="9">Cobia (Ling)</option> <option value="10">Flounder</option> <option value="11">Tarpon</option> <option value="12">Tripletail</option> <option value="13">Permit</option> <option value="14">Blackfin Tuna</option> <option value="15">Yellowfin Tuna</option> <option value="16">Barracuda</option> <option value="17">Bonefish</option> <option value="18">Dorado</option> <option value="19">Wahoo</option> <option value="20">Billfish</option> </select> <span class="style2"> <label>Quantity</label> </span> <label> <input name="quantity" type="text" id="quantity" size="3" maxlength="2" /> </label> <span class="style2"> <label>Total Points</label> </span> <label> <input name="points" id="points" onBlur="calc_points();"> </body> </html> Link to comment https://forums.phpfreaks.com/topic/90542-function-calculate-problem/ Share on other sites More sharing options...
mainewoods Posted February 11, 2008 Share Posted February 11, 2008 var quantity2 = document.getElemendById("quantity").value; spelling error in getElemendById Link to comment https://forums.phpfreaks.com/topic/90542-function-calculate-problem/#findComment-464239 Share on other sites More sharing options...
Skipjackrick Posted February 11, 2008 Author Share Posted February 11, 2008 var quantity2 = document.getElemendById("quantity").value; spelling error in getElemendById OH GOD!!! Thanks...hahaha Link to comment https://forums.phpfreaks.com/topic/90542-function-calculate-problem/#findComment-464268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.