Page 1 of 1

Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 1:31 pm
by Squiggle Master

I did the following.
Clicked on the button, Opened events, Selected event click, Selected action run javascript, and typed this in:
function convertToC() {
var fTempVal = parseFloat(Appery("mobiletextinput_10").val());
var cTempVal = (fTempVal - 32) * (5 / 9);
document.getElementById('cTemp').value = cTempVal;
return false;
}

I'm not sure why it is not working can anybody help?


Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 1:44 pm
by Igor

Do you invoke this function on button click?
Are there any JS errors in browser console? http://docs.appery.io/documentation/d...


Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 1:56 pm
by Squiggle Master

It has this error: event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
But in the javascript creator there don't seem to be any errors. The linking may not be correct.


Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 2:02 pm
by Igor

Please share app link with us http://docs.appery.io/documentation/s...


Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 2:10 pm
by Squiggle Master

Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 2:12 pm
by Squiggle Master

Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 2:30 pm
by Igor

Replace your code with the following:

pre
code
function convertToC() {
var fTempVal = parseFloat(Appery("mobiletextinput_10").val());
var cTempVal = (fTempVal - 32) * (5 / 9);
Appery("temperature2").text(cTempVal);
return false;
}
convertToC();
/code
/pre


Javascript Farenheit To Celsius Linking To Button Problem

Posted: Sun Feb 09, 2014 7:29 pm
by Squiggle Master

Thanks it works!