Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:

TOPIC: prefill answer of single choice via js

prefill answer of single choice via js 5 years 10 months ago #56081

  • KRav
  • KRav's Avatar
  • Offline
  • Gold Lime
  • Posts: 184
  • Thank you received: 16
  • Karma: 8
hi, I'm wodering, how to prefill a single choice answer via js?
this is not working :


<script type="text/javascript" charset="utf-8"> jQuery(document).ready(function($) { var role = '{INSERTANS:54579X4X39}'; document.getElementById('answer54579X20X244').value= 'A2'; // or '{A1}' is not working } }); </script> code][code]
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function($)
{
var role = '{INSERTANS:54579X4X39}';
document.getElementById('answer54579X20X244').value= 'A2'; // or '{A1}' is not working
}

});
</script>

code]

research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.
The administrator has disabled public write access.

prefill answer of single choice via js 5 years 10 months ago #56095

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9600
  • Thank you received: 1376
  • Karma: 390
Hello,

You have to use .attr jquery function.

Without testing:
$("input#answer54579X20X244A2").attr('checked', true);
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (use private message).
The administrator has disabled public write access.

prefill answer of single choice via js 5 years 10 months ago #56157

  • KRav
  • KRav's Avatar
  • Offline
  • Gold Lime
  • Posts: 184
  • Thank you received: 16
  • Karma: 8
Thanks

research on BLOGS - Professional LimeSurvey support
Consultant - Templates - Training - JQuery magic - Support - Coding - Survey creation and more..

Contact
Professional LimeSurvey support
This email address is being protected from spambots. You need JavaScript enabled to view it.
The administrator has disabled public write access.

prefill answer of single choice via js 5 years 10 months ago #56178

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6029
  • Thank you received: 373
  • Karma: 260
You're welcome!

If our hints have been helpful and you enjoy limesurvey please consider a donation to the team .
We do all this in our free time and you don't have to pay a penny for this software.

Without your help we can't keep this project alive.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
The administrator has disabled public write access.
Time to create page: 0.600 seconds
Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form