Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: prefill answer of single choice via js

prefill answer of single choice via js 2 years 4 months ago #56081

  • ResearchOnBlogs
  • ResearchOnBlogs'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 e-mail address is being protected from spambots. You need JavaScript enabled to view it
The administrator has disabled public write access.

Re: prefill answer of single choice via js 2 years 4 months ago #56095

  • DenisChenu
  • DenisChenu's Avatar
  • NOW ONLINE
  • Moderator Lime
  • Posts: 4521
  • Thank you received: 472
  • Karma: 168
Hello,

You have to use .attr jquery function.

Without testing:
$("input#answer54579X20X244A2").attr('checked', true);
The administrator has disabled public write access.

Re: prefill answer of single choice via js 2 years 4 months ago #56157

  • ResearchOnBlogs
  • ResearchOnBlogs'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 e-mail address is being protected from spambots. You need JavaScript enabled to view it
The administrator has disabled public write access.

Re: prefill answer of single choice via js 2 years 4 months ago #56178

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5118
  • Thank you received: 264
  • Karma: 241
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)limesurvey.org'"
The administrator has disabled public write access.
  • Page:
  • 1
Moderators: DenisChenu, ITEd
Time to create page: 0.252 seconds
Donation Image