I need 2 functions that take the value of a input
and send it to another input
this value +2, I had already asked this question here but it was for +3 and I got the solution, however I did another function with other name and other fields, and the result was NaN
. Here is the code for +3 that works:
function tenta() {
if(document.getElementById('ciclo').value == "")
{
document.getElementById('ciclo2').value = "2013"; //placeholder
document.getElementById('ciclo2').style.color = "#bfbfbf";
}else
{
document.getElementById('ciclo2').style.color = "black";
var x = document.getElementById('ciclo').value;
document.getElementById('ciclo2').value = parseFloat(x) + 3;
}
}
and function equal, but returns NaN
:
function numeros2()
{
if(document.getElementById('ciclo3').value == "")
{
document.getElementById('ciclo4').value = "2013"; //placeholder;
document.getElementById('ciclo4').style.color = "#bfbfbf";
}else
{
document.getElementById('ciclo4').style.color = "black";
var xy = parseInt(document.getElementById('ciclo4').value);
document.getElementById('ciclo4').value = xy + 2;
}
}
I have tried parseFloat
, but it also does not work.