Solved
How to get a result of a math operation within the same page?
Hello!
I have a question in which the respondent have to choose a product and then how much of it they would like to buy. I would like to add a feature in which in the moment they select the amount, they can see how much they would have to pay for it. Everything in the same page. I called the customer service but they told me that this feature requieres Java script, but I am not so good in it. Does anybody has previusly used a similar code that I could adapt to my survey?
Thank you!
Best answer by Anonymous
hello @ecd921,
Agreed with @srane , here's the implementation of the question. For eg there are four products and has price 1, 2, 3, 4. Add the following script in the header of the survey i.e go to look and feel -> advanced -> header (click edit):
<script>
document.getElementById('QR~QID2').setAttribute("onkeyup","myfun()");
function myfun(){
var pcost;
var that1=document.getElementById('QR~QID1~20');
if(that1.checked){
var pcost=1;
}
var that2=document.getElementById('QR~QID1~21');
if(that2.checked){
var pcost=2;
}
var that3=document.getElementById('QR~QID1~22');
if(that3.checked){
var pcost=3;
}
var that4=document.getElementById('QR~QID1~23');
if(that4.checked){
var pcost=4;
}
var val=document.getElementById('QR~QID2').value;
//alert (val);
var t=val * pcost;
document.getElementById('tt').innerHTML=t;
}
</script>
You can find the survey qsf here.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.