Welcome, Guest
Username: Password: Remember me

TOPIC: prefill answer of single choice via js

prefill answer of single choice via js 3 years 9 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 email 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 3 years 9 months ago #56095

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6551
  • Thank you received: 869
  • Karma: 257
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 3 years 9 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 email 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 3 years 9 months ago #56178

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5425
  • Thank you received: 307
  • Karma: 252
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.
Moderators: ITEd
Time to create page: 0.109 seconds
Donation Image