Hi,
I wrote this function and the function works as long as I pass along the input fields that it needs to run the function. I've been looking at function examples and I see a lot of using "this" in the function argument. I try to do this and it never works. It always says that "Object Expected". Can someone explain to me why using this doesn't work? I know there is an easier way to pass values into functions other that listing all of the input names in the argument. Is there?
HTML
Thanks
I wrote this function and the function works as long as I pass along the input fields that it needs to run the function. I've been looking at function examples and I see a lot of using "this" in the function argument. I try to do this and it never works. It always says that "Object Expected". Can someone explain to me why using this doesn't work? I know there is an easier way to pass values into functions other that listing all of the input names in the argument. Is there?
Code:
<script language="javascript" type="text/javascript">
function calculateShip(item_quantity_1, ship_method_price_1){
if(document.buynow.item_quantity_1.value <= 25){
var grdship = 7.95;
}
else if((document.buynow.item_quantity_1.value >= 26) && (document.buynow.item_quantity_1.value <= 50)){
var grdship = 10.95;
}
else if((document.buynow.item_quantity_1.value >= 51) && (document.buynow.item_quantity_1.value <= 75)){
var grdship = 13.95;
}
else if((document.buynow.item_quantity_1.value >= 76) && (document.buynow.item_quantity_1.value <= 100)){
var grdship = 16.95;
}
else if(document.buynow.item_quantity_1.value >= 100){
var grdship = 20.95;
}
document.buynow.ship_method_price_1.value = grdship;
}//end of function
</script>
HTML
Code:
<input type="text" name="item_quantity_1" value="0" size="3" onchange="return calculateShip(item_quantity_1.value, ship_method_price_1.value)"/>
Thanks