Hunter Hansen
Posts: 0
Joined: Fri Mar 14, 2014 2:13 pm

calculating values from select component

I have a rating scale select component for 2 questions (item1, item2). the values are numbers. I want to add numbers but when I do I get NaN. Heres my javascript.

var n1 = parseInt(Appery("item1").val()), n2 = parseInt(Appery("item2").val());
Appery("totalnum").text(n1+n2);

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

calculating values from select component

Hello,

Which value is in item1 component?
Please display this value with alert():

alert(Appery("item1").val());

Hunter Hansen
Posts: 0
Joined: Fri Mar 14, 2014 2:13 pm

calculating values from select component

"the page at appery.io says: "

blank

you can see it here
http://appery.io/app/mobile-frame?src...

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

calculating values from select component

Hi,

Your problem is that you are using the custom component. Therefore, you should use custom component name when you refer to "select" element. In other words, just replace this code:

var n1 = parseInt(Appery("item1").val()), n2 = parseInt(Appery("item2").val());

with:

var n1 = parseInt(Appery("item1_item1").val()), n2 = parseInt(Appery("item2_item1").val());

Hunter Hansen
Posts: 0
Joined: Fri Mar 14, 2014 2:13 pm

calculating values from select component

thank you!!!!!!!!!!!!!!!!!!!!!!

Return to “Issues”