I use a code to display some radio buttons, but this code and values are loaded dynamically, so I cannot add checked to the html.
The differences between the radio buttons are values.
Is there a way to let value 1 be selected by default?
Code:
<div class="input-box">
<strong><?php echo $this->__('Would you recommend this product to a friend?') ?></strong>
<?php foreach ( $this->getOptions() as $option ): ?>
<label class="recommend">
<input type="radio" name="recommend" id="recommend_field" class="radio-gender" value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' checked="checked"' ?>><?php echo $this->__($option['label']) ?></input>
</label>
<?php endforeach ?>
</div>
Please try bellow code to select first radio button on page load
here is the working demo http://jsfiddle.net/patelmit69/j25w4f7z/1/