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

TOPIC: Update variables‏

Update variables‏ 5 years 4 months ago #58333

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
I need again help.
The question Q11 is a type of array numbers
The question Q12 is the same type.
I have a question hide with a script to charge the sum of the two variables.
Q11 -> x1
Q12 -> x2
Script -> x1+x2= y1
<script type="text/javascript" charset="utf-8">

$(document).ready(function(){
var val5 = "{INSERTANS:66315X78X9935}";
var val6 = "{INSERTANS:66315X78X9936}";
//var hola = 123;
if (val5 =="") {val5=0;}
if (val6 =="") {val6=0;}
var otro = parseInt(val5) + parseInt(val6);

// call the functions with the hidden timer question ID
runTimer(1319,otro);

function runTimer(timeQID,valor) {
$('#question'+timeQID).hide();
var fec=Date();
$('#question'+timeQID+' input.text').val(valor);
}
});

</script>
I have another similar questions, but these questions are in other page.
Q21 -> z1
Q22 -> z2
z1+z2= y1


I have a problem: y1 not updated (NaN), but if I came back previous page, y1 would update.

How could I do in order to y1 update?
The administrator has disabled public write access.

Update variables‏ 5 years 4 months ago #58338

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 6122
  • Thank you received: 1357
  • Karma: 533
Are the "val5" question and the "val6" question on a previous page? {INSERTANS} only works with questions from a previous page.

Are the SGQAs correct? Try:
alert ('{INSERTANS:66315X78X9935}, {INSERTANS:66315X78X9936}');

Try replacing:
var otro = parseInt(val5) + parseInt(val6);
With:
var otro =Number(val5) + Number(val6);

Why is "var fec=Date();" there? I see no reason for it.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The administrator has disabled public write access.

Update variables‏ 5 years 4 months ago #58344

  • rafael_ur
  • rafael_ur's Avatar
  • Offline
  • Senior Lime
  • Posts: 74
  • Karma: 0
Hi Tony:

Hi changed parseInt for Number and it is OK.

As var=Date() is useless.

Many thanks,

Rafael
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.298 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form