Page 1 of 1

Get number from input, button onclick put number in label using event / javastript.

Posted: Sat Aug 09, 2014 7:12 am
by Modern ShowJumping

Hi. I've tried to work this out... I have limited code experience (I can read it no worries, but writing from scratch... I didn't learn JavaScript). I am trying to create an input field (number), which when the button is clicked, will result in the number in the label.

I just want to set an event to run Javascript.

Would somebody be so kind as to write this for me?

Its just

user inputs a number

Button.onclick (take number and put it in the label)

I will use that number for calculations... I just need this bit and I'll be right to continue on my own.

Please be kind! :-)


Get number from input, button onclick put number in label using event / javastript.

Posted: Sat Aug 09, 2014 7:15 am
by Modern ShowJumping

This is my code, which doesn't work.

________________________________

Code: Select all

 function calculate() 
 { 

  var param1 = parseFloat(document.getElementById(inputField).value); 

  var tometers = (param1  / 3.28083989501312 * 12);  

  if (!isNaN(tometers)) 
  { 
   document.getElementById("tometers").innerHTML = tometers.toFixed(2) + " meters.  

Between jumps it is " +tometers2.toFixed(1)+ " meters
allowing for landing and take-off.";
}

Code: Select all

  else 
  { 
   document.getElementById("tometers").innerHTML = "bummer"; 
  }

Get number from input, button onclick put number in label using event / javastript.

Posted: Sat Aug 09, 2014 9:26 am
by Alena Prykhodko

Hi,

To put input value to label you can Run the following code on button Click event:

prevar input = Appery('inputName').val();
Appery('labelName').text(input);/pre

where inputName - name of input component;
labelName - name of label component.


Get number from input, button onclick put number in label using event / javastript.

Posted: Sat Aug 09, 2014 9:49 am
by Modern ShowJumping

Great thanks. I'll check out how to do that with numbers...

Thanks again.