![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
It looks like javascript doesn´t have time to update the aux variable to send it properly as an output... does anyone know how to fix this problem? |
#3
| |||
| |||
|
|
Hi everybody! I am trying to program a function in javascript and a funny behaviour occurs. If I execute this code: aux=parseInt(year-birthyear); return (aux) The value that the output returns is NaN (Not a number) but if I execute this another one... aux=parseInt(year-birthyear); alert('hi') return (aux) Then the value that the output returns is right It looks like javascript doesn´t have time to update the aux variable to send it properly as an output... does anyone know how to fix this problem? Thanks a lot! Victor |
#4
| |||
| |||
|
|
It looks like javascript doesn´t have time to update the aux variable to send it properly as an output... does anyone know how to fix this problem? This shouldn't be the case. try parseInt(year)-parseInt(birthyear); |
#5
| |||
| |||
|
|
Pete wrote: It looks like javascript doesn´t have time to update the aux variable to send it properly as an output... does anyone know how to fix this problem? This shouldn't be the case. try parseInt(year)-parseInt(birthyear); Very true, but do you believe that the alert fixes this somehow? Regards, Erwin Moller |
#6
| |||
| |||
|
|
Hi everybody! I am trying to program a function in javascript and a funny behaviour occurs. If I execute this code: aux=parseInt(year-birthyear); return (aux) The value that the output returns is NaN (Not a number) but if I execute this another one... aux=parseInt(year-birthyear); alert('hi') return (aux) Then the value that the output returns is right It looks like javascript doesn´t have time to update the aux variable to send it properly as an output... does anyone know how to fix this problem? Thanks a lot! Victor |
#7
| |||
| |||
|
|
Hi everybody! I am trying to program a function in javascript and a funny behaviour occurs. If I execute this code: aux=parseInt(year-birthyear); |
#8
| |||
| |||
|
|
aux=parseInt(year-birthyear); |
![]() |
| Thread Tools | |
| Display Modes | |
| |