Welcome, Guest
Username: Password: Remember me

TOPIC: Default answer in array with 1 subquestion and 7 answer options

Default answer in array with 1 subquestion and 7 answer options 1 year 6 months ago #90764

  • scolwell
  • scolwell's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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
The administrator has disabled public write access.

Re: Default answer in array with 1 subquestion and 7 answer options 1 year 6 months ago #90765

  • scolwell
  • scolwell's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Sorry the picture was in the wrong format. Here it is again,
question.jpg
The administrator has disabled public write access.

Re: Default answer in array with 1 subquestion and 7 answer options 1 year 6 months ago #90769

  • scolwell
  • scolwell's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
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>
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.100 seconds
Donation Image