Vince P
Vince P

Reputation: 1791

Changing a label on a radio button

I have the following code (which is created dynamically by Magento) and I need to highlight the radio button label that has been selected.

How would I go about this? I tried using a image replacement script for the radio button itself which run using Mootools but this conflicts with prototype.js in the magento core.

All I need is to be able to change the highlighting on the label of selected option, so add a border etc... to the selected label.

Could someone point me in the correct direction?

<div class="product-options-title">
  <dt>
    <label class="required"> <em>*</em> Edge Details</label>
  </dt>
</div>
<div class="product-options-chooser">
  <dd class="options-last">
    <div class="input-box">
      <ul id="options-3318-list" class="options-list">
        <li>
          <input type="radio" class="radio  validate-one-required-by-name product-custom-option" onClick="opConfig.reloadPrice()" name="options[3318]" id="options_3318_2" value="548258"  price="0" />
          <span class="label">
          <label for="options_3318_2">
          <img src="http://www.justkitchens.co/media/doors/zurfiz/zurfiz_ultragloss_black_matching.jpg" />
          <div class="edge-option">Matching</div>
          </label>
          </span><script type="text/javascript">$('options_3318_2').advaiceContainer = 'options-3318-container';$('options_3318_2').callbackFunction = 'validateOptionsCallback';</script></li>
        <li>
          <input type="radio" class="radio  validate-one-required-by-name product-custom-option" onClick="opConfig.reloadPrice()" name="options[3318]" id="options_3318_3" value="548259"  price="0" />
          <span class="label">
          <label for="options_3318_3">
          <img src="http://www.justkitchens.co/media/doors/zurfiz/zurfiz_ultragloss_black_brushed_steel.jpg" />
          <div class="edge-option">Stainless Steel Effect</div>
          </label>
          </span><script type="text/javascript">$('options_3318_3').advaiceContainer = 'options-3318-container';$('options_3318_3').callbackFunction = 'validateOptionsCallback';</script></li>
        <li>
          <input type="radio" class="radio  validate-one-required-by-name product-custom-option" onClick="opConfig.reloadPrice()" name="options[3318]" id="options_3318_4" value="548260"  price="0" />
          <span class="label">
          <label for="options_3318_4">
          <img src="http://www.justkitchens.co/media/doors/zurfiz/zurfiz_ultragloss_black_glass.jpg" />
          <div class="edge-option">Glass Effect</div>
          </label>
          </span><script type="text/javascript">$('options_3318_4').advaiceContainer = 'options-3318-container';$('options_3318_4').callbackFunction = 'validateOptionsCallback';</script></li>
      </ul>
      <span id="options-3318-container"></span> </div>
  </dd>
</div>

Upvotes: 0

Views: 985

Answers (1)

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76880

You could do (i use live since content is generated):

$('input:radio').live('click', function(){
   if($(this).is(':checked')){
       $(this).next('span').addClass('border');
   }else{
       $(this).next('span').removeClass('border')
   }
});

and then define a css class:

label.border{

  border: 1px solid red;
}

Upvotes: 3

Related Questions