Modern ShowJumping
Posts: 0
Joined: Sat Aug 09, 2014 7:12 am

Dingbat wants to add two numbers! Can't find the doco anywhere. Its simple I know. I'm new here and to JavaScript. Pleas

I'm a bit frustrated... I coded many years ago, so I can read it no worries at all, but I don't know the syntax for JavaScript..I did C++ and Eiffel. I can't find anywhere in the doco how to add 2 numbers!! What I'm trying to do is (get a number) from an input field, and perform a calculation, and put it in an output field. I can do this with text.

One of you lovely folks gave me the code for doing this in text... I see the second line is converting the input to text, but I want it to be a number. I have tried "float", but as you can see, I don't know what I'm doing.

To make this more complicated... I have a drop down list... and on change of the values, I want to apply a different formula ... but if I could just work out how to do this float thing, and the syntax for merely adding two numbers that'd go a long way!

http://modernshowjumping.weebly.com/d...

See my android one here: http://modernshowjumping.weebly.com/f... (Show Jump Distance Converter).

ARGH!!!!!!!!!!!!!!!!!!!!!!

This is turning me to alcohol. :-s

var input = Appery('inputfield').val();
Appery('topaces').text(input);

//Appery(input).float(input).val(1);

Modern ShowJumping
Posts: 0
Joined: Sat Aug 09, 2014 7:12 am

Dingbat wants to add two numbers! Can't find the doco anywhere. Its simple I know. I'm new here and to JavaScript. Pleas

OK, so I finally found this.

http://api.jquery.com/Types/#Number

But still need help with this line

Appery('topaces').text(input);

Do I make it

var input = Appery('inputfield').val();
Appery('topaces').float("input")+1;

where "inputfield" is my input field.
"topaces" is my output label.

ARGH

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Dingbat wants to add two numbers! Can't find the doco anywhere. Its simple I know. I'm new here and to JavaScript. Pleas

Hi -

Should be something like this:
precode
var input = Appery('inputfield').val();
Appery('topaces').text(parseFloat(input) + 1);
/code/pre

Return to “Issues”