...

View Full Version : JS Semi-Newby needin' some help



saint681
08-16-2005, 09:38 PM
I'm really good with JS normally, but I'm having to use existing code to make this work. And IE keeps bringing back errors. :confused:


function getPrice()
{
theForm = document.form2 ;
var price = "<? echo $price ; ?>" ;
var on_sale_discount = "<? echo $on_sale_discount ; ?>" ;
var description_short = "<? echo $description_short ; ?>" ;
var product_no = "<? echo $product_no ; ?>" ;
var qty = theForm.qty.value ;

price = (price * (100 - on_sale_discount) * .01) ;
price = parseFloat(price) * parseFloat(qty) ;

var gaines-kdx_price = "<? echo $gaines-kdx_price ; ?>" ;
var gaines-kdx = theForm.gaines-kdx.options[theForm.gaines-kdx.selectedIndex].value ;
var gaines-kdx_type = "<? echo $gaines-kdx_type ; ?>" ;
var description_short = "<? echo $description_short ; ?>" ;

if (gaines-kdx == "Yes")
{
gaines-kdx_price = parseFloat(gaines-kdx_price) * parseFloat(qty) ;
gaines-kdx_price = format(gaines-kdx_price) ;
theForm.gaines-kdx_price.value = gaines-kdx_price ;
price = parseFloat(price) + parseFloat(gaines-kdx_price) ;
description_short = description_short + "<br>. " + gaines-kdx_type ;
}
else
{
theForm.gaines-kdx_price.value = '0.00' ;
theForm.option_1.value = "" ;
}


var "gaines-ksp" = theForm.gaines-ksp.options[theForm.gaines-ksp.selectedIndex].value ;

if (gaines-ksp == "Yes")
{
var gaines-ksp_price = "<? echo $gaines-ksp_price ; ?>" ;
gaines-ksp_price = parseFloat(gaines-ksp_price) * parseFloat(qty) ;
gaines-ksp_price = format(gaines-ksp_price) ;
theForm.gaines-ksp_price.value = gaines-ksp_price ;
price = parseFloat(price) + parseFloat(gaines-ksp_price );
description_short = description_short + "<br>. Keystone Standard Post" ;
theForm.option_2.value = "gaines-ksp" ;
}
else
{
theForm.gaines-ksp_price.value = '0.00' ;
theForm.option_2.value = "" ;
}


var "gaines-kdd" = theForm.gaines-kdd.options[theForm.gaines-kdd.selectedIndex].value ;

if (gaines-kdd == "Yes")
{
var gaines-kdd_price = "<? echo $gaines-kdd_price ; ?>"
gaines-kdd_price = parseFloat(gaines-kdd_price) * parseFloat(qty) ;
gaines-kdd_price = format(gaines-kdd_price) ;
theForm.gaines-kdd_price.value = gaines-kdd_price ;
price = parseFloat(price) + parseFloat(gaines-kdd_price) ;
description_short = description_short + "<br>. Keystone Double Post" ;
theForm.option_3.value = "gaines-kdd" ; // hidden value
}
else
{
theForm.gaines-kdd_price.value = '0.00' ;
theForm.option_3.value = "" ;
}


price = format(price) ;
theForm.price.value = price ;

theForm.description.value = description_short ; //hidden field to be passed to shopping cart.
}

saint681
08-16-2005, 09:57 PM
Is it the dashes that are messing it up .. and if I remove .. would that mess with my php? lol

saint681
08-16-2005, 10:15 PM
Well, removing everything BUT this part .. made my getPrice() work fine again: But, I still can't get the Yes/No options to work.

http://agi.proxytools.net/keystone/gaines-KS-3A

If you try any other product under Keystone, for some reason the loop never stops.


function getPrice()
{
theForm = document.form2 ;
var price = "<? echo $price ; ?>" ;
var on_sale_discount = "<? echo $on_sale_discount ; ?>" ;
var description_short = "<? echo $description_short ; ?>" ;
var product_no = "<? echo $product_no ; ?>" ;
var qty = theForm.qty.value ;

price = (price * (100 - on_sale_discount) * .01) ;
price = parseFloat(price) * parseFloat(qty) ;
price = format(price) ;
theForm.price.value = price ;

theForm.description.value = description_short ; //hidden field to be passed to shopping cart.
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum