Changing from drop down to ratio buttons problem

Discussion in 'JavaScript' started by falco85, Dec 4, 2005.

  1. #1
    Hi, having an issue there changing from drop-down to ratio buttons

    Here is the original drop down code:

    
    <select name="VariantProductOption_ID" id="VariantProductOption_ID3" style="font-family: Verdana; font-size: 8pt" size="1" onchange="changePriceValue()">
    				
    								<option value="6" >17" 1680 x 1050 UltraPix WSXGA+ Glassview LCD</option>
    								
    								<option value="7" >17" 1920 x 1200 UltraPix WUXGA+ w/ GlassView LCD [ADD $150.00]</option>
    								
    						 </select>
    
    Code (markup):
    Here is the radio button version:
    
    <fieldset>
    
        <legend>Display</legend>
    
        <ul>
          <li>
            <label>
              <input type="radio" name="VariantProductOption_ID" id="VariantProductOption_ID3" value="6" onclick="changePriceValue()">
              17" 1680 x 1050 UltraPix WSXGA+ Glassview LCD
            </label>
          </li>
    
          <li>
            <label>
              <input type="radio" name="VariantProductOption_ID" id="VariantProductOption_ID3" value="7" onclick="changePriceValue()">
              17" 1920 x 1200 UltraPix WUXGA+ w/ GlassView LCD [ADD $150.00]
            </label>
          </li>
        </ul>
    
      </fieldset>
    
    Code (markup):
    And this is the .js behind:

    
    <script language="javascript">
    			   					
    				
    				function changePriceValue()
    				{
    				
    					
    						if (document.getElementById('strRealPricePass65')){	
    							var ListPrice = document.getElementById('strRealPricePass65').value
    						}else{
    							var ListPrice = 0
    						}
    						
    						
    						if (document.getElementById('strStrikePricePass65')){	
    							var StrikePrice = document.getElementById('strStrikePricePass65').value
    						}else{
    							var StrikePrice = 0
    						}
    						curTotalPriceOfVariants = 0
    						curTotalPartMod = ""
    						//curTotalMfgPartMod = ""
    
    						strVariantProduct_IDs = document.getElementById('VariantProduct_IDs').value
    						aryVariantProduct_IDs = strVariantProduct_IDs.split(',')
    					
    						var VariantProductOptions_IDs
    						VariantProductOptions_IDs = ""
    						for (i=0;i<aryVariantProduct_IDs.length;i++){
    							VariantProductOption_ID = document.getElementById("VariantProductOption_ID" + aryVariantProduct_IDs[i]).value
    					
    							mod = document.getElementById("PriceMod" + VariantProductOption_ID).value
    							curTotalPriceOfVariants = curTotalPriceOfVariants + parseFloat(mod)
    							
    							mod = document.getElementById("PartMod" + VariantProductOption_ID).value
    							curTotalPartMod = curTotalPartMod + mod
    							
    							VariantProductOptions_IDs = VariantProductOptions_IDs + "," + VariantProductOption_ID
    
    							//mod = document.getElementById("MfgPartMod" + VariantProductOption_ID).value
    							//curTotalMfgPartMod = curTotalMfgPartMod + mod
    							
    						}
    					
    						document.getElementById('VariantProductOptions').value = VariantProductOptions_IDs
    						Discount = document.getElementById('discountPercentage').value	
    						NewPrice = parseFloat(ListPrice) + (parseFloat(curTotalPriceOfVariants) * parseFloat(Discount))
    					
    						
    					
    						if(document.getElementById('strStrikePrice')){
    								
    								document.getElementById('strStrikePrice').innerHTML = formatCurrency(parseFloat(StrikePrice) + parseFloat(curTotalPriceOfVariants))
    								
    								document.getElementById('ProdDisc65').value = formatCurrency(NewPrice)
    								document.getElementById('strProdPrice').value = formatCurrency(parseFloat(StrikePrice) + parseFloat(curTotalPriceOfVariants))
    								
    							}else{
    								document.getElementById('strProdPrice').value = formatCurrency(NewPrice)
    				
    							}
    					
    						NewMFGPartNumber = document.getElementById('strProductMFGPartNumber').innerHTML //+ curTotalMfgPartMod
    						//document.getElementById('strProductMFGPartNumber').innerHTML = formatCurrency(NewMFGPartNumber)
    						NewPartNumber = document.getElementById('strProductPartNumberBase').value + curTotalPartMod
    											
    							document.getElementById('strProductPartNumber').innerHTML = NewPartNumber
    							
    						document.getElementById('PartNum').value = NewPartNumber
    						document.getElementById('MFGPartNum').value = NewMFGPartNumber
    						
    							document.getElementById('strRealPrice').innerHTML = '$' + formatCurrency(NewPrice)
    						
    					try{
    						changeQtyDisplayBox(NewPrice)
    					}catch(e){
    					}
    				}
    				
    				function numberorder(a,b){return a - b;}
    				
    				changePriceValue()
    				
    			</script>
    
    Code (markup):
    The radio button code, displays properly, but it doesn't update the price when you change the option, so I am thinking that the .js has to be changed in order to function with the radio button layout.

    Please, let me know if you have a solution,
    Thanks :)
     
    falco85, Dec 4, 2005 IP
  2. Michau

    Michau Well-Known Member

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Yes, you need to call the changePriceValue() function in onClick handler for your radiobuttons, and modify that function so that it determines the currently chosen element from radio buttons, not from drop-down list.
     
    Michau, Dec 5, 2005 IP