Jump to content

Function calculate problem


Skipjackrick

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.