Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

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

Can't update a prvious answer with javascript? 1 Jahr 8 Monate her #89468

  • garf
  • garfs Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 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>
 
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can't update a prvious answer with javascript? 1 Jahr 8 Monate her #89479

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6277
  • Dank erhalten: 801
  • Karma: 241
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
Letzte Änderung: 1 Jahr 8 Monate her von DenisChenu.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Re: Can't update a prvious answer with javascript? 1 Jahr 8 Monate her #89494

  • tpartner
  • tpartners Avatar
  • ONLINE
  • LimeSurvey Team
  • Beiträge: 4141
  • Dank erhalten: 767
  • Karma: 349
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 Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: DenisChenu

Aw: Re: Can't update a prvious answer with javascript? 1 Jahr 8 Monate her #89904

  • rupibed
  • rupibeds Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 3
  • Karma: 0
Please let us then how to modify previous questions?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Aw: Re: Can't update a prvious answer with javascript? 1 Jahr 8 Monate her #89905

  • DenisChenu
  • DenisChenus Avatar
  • OFFLINE
  • Moderator Lime
  • Beiträge: 6277
  • Dank erhalten: 801
  • Karma: 241
rupibed schrieb:
Please let us then how to modify previous questions?
You can't.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.155 Sekunden
Donation Image