Answer the question
In order to leave comments, you need to log in
How to set checked in the required 'input' for a specific form with its 'id'?
There is an array with values 'data = [ 5, 5, 5]' . There are also 3 forms with different 'id' in which the rating is . Based on the assessment, you need to fix the 5th radio button.
<input class="rating-input" id="mod1'" name="radio-rating" type="radio" value="1">
<label class="rating-star" for="mod1" ></label>
<input class="rating-input" id="mod2" name="radio-rating" type="radio" value="2">
<label class="rating-star" for="mod2"></label>
<input class="rating-input" id="mod3" name="radio-rating" type="radio" value="3">
<label class="rating-star" for="mod3"></label>
<input class="rating-input" id="mod4" name="radio-rating" type="radio" value="4">
<label class="rating-star" for="mod4"></label>
<input class="rating-input" id="mod5" name="radio-rating" type="radio" value="5">
<label class="rating-star" for="mod5"></label>
Answer the question
In order to leave comments, you need to log in
<?php $checked = 5;
$count = 5;
?>
<?php for($i = 1; $i <= $count; $i++): ?>
<?php if($i == $checked):?>
<input class="rating-input" id="mod<?=$i?>'" name="radio-rating" type="radio" value="<?=$i?>" checked>
<label class="rating-star" for="mod<?=$i?>" ></label>
<?php else:?>
<input class="rating-input" id="mod<?=$i?>'" name="radio-rating" type="radio" value="<?=$i?>">
<label class="rating-star" for="mod<?=$i?>" ></label>
<?php endif;?>
<?php endfor;?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question