doubleimpact
Technical User
Chessbot helped out wonderfully before and offered the following code. I am just now getting back on this and can't seem to get this to work. So I'll leave it to the experts here.
The rest of the story is I have a drop down menu that a customer should choose if they want shipping insurance or not. The default is no. But when they change it I want to be sure that the javascript changes the value shipins to the amount to add for shipping insurance.
You will see in the code below, I have added the shipins as a input field, I will hide this in the final version. I just like to see it while I am testing to make sure the values are calculated correctly.
I have tried a couple of variations and changes, but my disgraceful understanding of Javascript fails me everytime.
Could you please tell me what I am doing wrong?
P.S. Is there any way to have one javascript run several javascripts in a specified order?
Code:
<script>
<!-- Calculate shipping insurance rate, given by chessbot on tek-tips.com -->
var inc = 100; // increment
var fee = 2; // fee per increment
function getInsurance(amount)
{
var total = parseInt(amount);
total += Math.floor(amount/inc) * fee;
return total;
}
</script>
The rest of the story is I have a drop down menu that a customer should choose if they want shipping insurance or not. The default is no. But when they change it I want to be sure that the javascript changes the value shipins to the amount to add for shipping insurance.
You will see in the code below, I have added the shipins as a input field, I will hide this in the final version. I just like to see it while I am testing to make sure the values are calculated correctly.
Code:
<tr>
<td><b>Shipping Insurance (Optional): </b><br><font size=1>$2.00 for every $100</font></td>
<td colspan=2>
<select name="shipinschoice" onchange="getInsurance()">
<option>Add Shipping Insurance (+$2 per $100)</option>
<option value="0" selected>No Shipping Insurance (Free)</option>
</select> <input type="text" name="shipins" size="10">
</tr>
I have tried a couple of variations and changes, but my disgraceful understanding of Javascript fails me everytime.
Could you please tell me what I am doing wrong?
P.S. Is there any way to have one javascript run several javascripts in a specified order?