JS Using array to show text after drop down selected

zayjack

New Member
Ok so I have some code that works perfectly for the first product I added into my store. But when I add the next product the drop down options auto increment the ID value in the selection. I need to find a way around this so it works on any product that is loaded.Here is the Javascript:\[code\] <script language="javascript"> function displayCondition() { condition = new Array("Please Select a Condition.","<b>Perfect:</b> Text to explain perfect condition!", "<b>Excellent:</b> Text to explain excellent condition!", "<b>Good:</b> Text to explain good condition!", "<b>Poor:</b> Text to explain poor condition!", "<b>Broken:</b> Text to explain broken condition!"); var getsel = document.getElementById('select_<?php echo $_option->getId();?>').value; document.getElementById("divId").innerHTML = condition[getsel]; }</script>\[/code\]Here is the working products code notice the IDs are 1-5:\[code\] <select name="options[1]" id="select_1" class=" required-entry product-custom-option" title="" onchange="opConfig.reloadPrice();displayCondition()"><option value="" >-- Please Select --</option><option value="http://stackoverflow.com/questions/15718854/1" price="0" >Perfect </option><option value="http://stackoverflow.com/questions/15718854/2" price="-35" >Excellent </option><option value="http://stackoverflow.com/questions/15718854/3" price="-105" >Good </option><option value="http://stackoverflow.com/questions/15718854/4" price="-140" >Poor </option><option value="http://stackoverflow.com/questions/15718854/5" price="-252" >Broken </option></select> \[/code\]And the code for the second product. Each product after this will keep incrementing:\[code\] <select name="options[6]" id="select_6" class=" required-entry product-custom-option" title="" onchange="opConfig.reloadPrice();displayCondition();"><option value="" >-- Please Select --</option><option value="http://stackoverflow.com/questions/15718854/13" price="0" >Perfect </option><option value="http://stackoverflow.com/questions/15718854/14" price="-35" >Excellent </option><option value="http://stackoverflow.com/questions/15718854/15" price="-105" >Good </option><option value="http://stackoverflow.com/questions/15718854/16" price="-140" >Poor </option><option value="http://stackoverflow.com/questions/15718854/17" price="-252" >Broken </option></select> \[/code\]The help I need is in the javascript. I can not change the values in the select's since they control the pricing that will affect each product. Thank you in advance.
 
Back
Top