The LimeSurvey Fund-Raiser 2012 is complete. Thank you for donating a total of 25,000 USD!     List of donors »

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

TOPIC: Can't update a prvious answer with javascript?

Can't update a prvious answer with javascript? 5 months 2 weeks ago #89468

  • garf
  • garf's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 4
  • Karma: 0
Hi everyone,

This little glitch is driving me crazy and I hope someone can point me in the right direction. I've been through everything I can Google in the groups and documents on this topic, but nothing seems to be working.

Simply, I want to update the value of a hidden question from an previous group based on responses from subsequent group questions. The final group has an equation question that runs the code below. I have to do this in script.

It seems so simple...but the values never stay and never update in the database. I've tried using plain numeric input questions and an equation type questions. nada ...

This is probably so obvious that I'm going to be embarrassed... :blush:


 
$(document).ready(function() {
   var T = 100;
   $('input#answerSSXGGXQQ').val(T);   //previous groups question
}
</script>
 
The administrator has disabled public write access.

Re: Can't update a prvious answer with javascript? 5 months 2 weeks ago #89479

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 4374
  • Thank you received: 451
  • Karma: 165
Hello,

With a short text question, try:
$("#question{QID} input.text").val(T);

AND you loose e ); at the end. Please see your javascript console log.

Denis

PS: look at tpartner answer too.
|
|
V
Last Edit: 5 months 2 weeks ago by DenisChenu.
The administrator has disabled public write access.

Re: Can't update a prvious answer with javascript? 5 months 2 weeks ago #89494

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 2853
  • Thank you received: 423
  • Karma: 243
You can't use JavaScript to modify the value of a question from a previous group. JavaScript can only modify elements in the current page.
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: DenisChenu

Aw: Re: Can't update a prvious answer with javascript? 5 months 1 week ago #89904

  • rupibed
  • rupibed's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Please let us then how to modify previous questions?
The administrator has disabled public write access.

Aw: Re: Can't update a prvious answer with javascript? 5 months 1 week ago #89905

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 4374
  • Thank you received: 451
  • Karma: 165
rupibed wrote:
Please let us then how to modify previous questions?
You can't.
The administrator has disabled public write access.
  • Page:
  • 1
Moderators: DenisChenu, ITEd
Time to create page: 0.228 seconds
Donation Image