- Posts: 3
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var thisQuestion = $('#question{QID}'); var q1Ans = ''; if($('input.radio:checked', thisQuestion).length > 0) { q1Ans = $('input.radio:checked', thisQuestion).attr('value'); if(q1Ans != "let's be friend") { alert("wrong!"); } }); }); </script>
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ $('#question{QID} input.radio').on('click', function(e){ var thisQuestion = $('#question{QID}'); alert(thisQuestion); // [object Object] }); }); </script>
Else : $('input.radio:checked', thisQuestion).attr('value') give the code, not the text …
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var correctCode = 'A1': $('#question{QID} input[type="radio"]').on('click', function(e){ var thisVal = $(this).val(); if(thisVal != correctCode) { alert('Wrong answer dummy!'); } }); }); </script>