Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

How to alert math with javascript?

Hey!
I have two Input(fields) that I have named "InOne" and "InTwo".

In this fields I want the user to input numbers, for example: InOne = 20 and InTwo = 2.
When the user click a button named "Calculate" I want a "alert window" to pop up where the answer is written (Answer = InOne/InTwo).
How can I make this to work with JavaScript (Event = Click, Action = Run JavaScript).

I have tried to make this to work for a week now but I cant make this work.

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to alert math with javascript?

Hello Nicklas,

You may try this code

codevar one, two;
one = parseInt(Appery("InOne").val());
two = parseInt(Appery("InTwo").val());
alert(one/two);/code

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

How to alert math with javascript?

Thank you very much!!

Another question

Is it possible to do the same but get the answer in another Input, or a label, textfield etc., not a alert?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to alert math with javascript?

Hello Nicklas,

You should use this code to write to label:

codeAppery("labelName").text(one/two);/code

instead of

codealert(one/two);/code

Please read more here http://devcenter.appery.io/documentat...

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

How to alert math with javascript?

No I meen:
I want the answer to show up in a label under the button, not an alert.

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

How to alert math with javascript?

Is it possible to do the same (Appery("labelName").text(one/two);) with a Input(field)?

Like Appery("InputName").text(one/two);. I tried this one, but it doesn't work.

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

How to alert math with javascript?

Oh! I need val instead of text... :) Thanks anyway:)

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

How to alert math with javascript?

Hello Nicklas,

Thank you for the update. Do not hesitate to contact us if you need any further help.

Return to “Issues”