I am using jquery raty (a rating script). I have multiple rating options and if none of them are selected the hidden post field that is generated doesnt exist. This is how I was able to name and pull the score selected for all 4 options.
<section>
<label>Option 1:</label>
<div class="options" data-score-name="option1"></div>
</section>
<section>
<label>Option 2:</label>
<div class="options" data-score-name="option2"></div>
</section>
<section>
<label>Option 3:</label>
<div class="options" data-score-name="option3"></div>
</section>
<section>
<label>Option 4:</label>
<div class="options" data-score-name="option4"></div>
</section>
<script type="text/javascript">
$('.options').raty({
half: true,
width: 'width: 150',
path: '/assets/img',
starOff: 'star-off.png',
starOn: 'star-on.png',
starHalf: 'star-half.png',
readOnly: false,
scoreName: 'score[]',
click: function(score)
{
var ScoreName = $(this).attr('data-score-name');
$(this).append("<input type='hidden' name='rate[" + ScoreName + "]' value='" + score + "'>");
}
});
</script>
The problem i'm having is , how do i make each option have a default value if its not selected? I'm not sure if there is a onload option that will give it a default value and was only able to use onclick.