magento - Display text when Select is chosen -
i have form select, radio , checkbox options. php builds array of options , designators assigned them. how display designator each option when option selected?
selects , options code:
<select onchange="bundle.changeselection(this)" id="option-1" name="bundle_option_1" class="option-1"> <option value="1">option1</option> </select> <ul class="options-list"> <li><input type="radio" onclick="bundle.changeselection(this)" class="radio" id="bundle-option-2-select-2" name="bundle_option_2" value="2"/></li> </ul> <ul class="options-list"> <li><input type="checkbox" onclick="bundle.changeselection(this)" class="checkbox" id="bundle-option-3-select-3" name="bundle_option_3" value="3"></li> </ul>
array generated:
array ( [0] => designator1 [1] => designator2 [2] => designator3 [3] => designator4 [4] => designator5 )
div display:
<div class="configuration" id="designator"></div>
thank you.
i don't know magento, seems need javascript (well prototypejs) solution, try this:
<script> document.observe('dom:loaded', function() { $$('[name^=bundle_option]').invoke('observe','click',function(e) { var el=e.element(), output=$('designator'); if(el.nodename=='select') { output.innerhtml=el.options[el.selectedindex].text; } else if(el.nodename=='input' && (el.type=='checkbox' || el.type=='radio')) { //- puts in value, prob not want //output.innerhtml = el.value; //- or if theres label //- (complete guess dont have html) //- find label input var label = el.up().select('label')[0]; //- grab text content , put in output div if(label) output.innerhtml = label.textcontent || label.innertext; } }); }); </script>
place code on page somewhere, cannot test let me know if right solution , if works!
Comments
Post a Comment