Default answer in array with 1 subquestion and 7 answer options

More
4 years 5 months ago #90764 by scolwell
scolwell created the topic: Default answer in array with 1 subquestion and 7 answer options
I have set up an array to act like a semantic differential question. See picture attached. I want the 4th radio button to be checked by default. Based on previous forum postings I am using the following code in the question source. This sets the first radio button to be the default, as per the picture, but I can't figure out how to get the 4th one as the default. Any thoughts?

<script type="text/javascript" charset="utf-8">

$(document).ready(function(){

var qID = 146174;

// Loop through the rows and check the first radio if none are already checked
$('#question'+qID+' table.question tbody tr').each(function(i) {
if($('input.radio:checked', this).length == 0) {
$('input.radio:eq(0)', this).attr('checked', true);
}
});
});

</script>

Thanks,

Scott

Please Log in to join the conversation.

More
4 years 5 months ago #90765 by scolwell
scolwell replied the topic: Default answer in array with 1 subquestion and 7 answer options
Sorry the picture was in the wrong format. Here it is again,
Attachments:

Please Log in to join the conversation.

More
4 years 5 months ago #90769 by scolwell
scolwell replied the topic: Default answer in array with 1 subquestion and 7 answer options
Got it! Found some code in another posting:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

if($('#question146372 input.radio:checked').length == 0) { document.getElementById('answer77551X11791X146372SQ1-A3').checked = 'checked';
}

});
</script>

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now