Check out the LimeSurvey source code on GitHub!

Update variables‏

More
5 years 11 months ago #58333 by rafael_ur
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?

Please Log in to join the conversation.

More
5 years 11 months ago #58338 by tpartner
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.

Please Log in to join the conversation.

More
5 years 11 months ago #58344 by rafael_ur
Hi Tony:

Hi changed parseInt for Number and it is OK.

As var=Date() is useless.

Many thanks,

Rafael

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form