Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy JS Semi-Newby needin' some help

    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.

    Code:
    	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.
    	}

  • #2
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry

    Is it the dashes that are messing it up .. and if I remove .. would that mess with my php? lol

  • #3
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    Code:
    	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.
    	}


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •