Jump to content

[SOLVED] Javascript returning NaN


stockton

Recommended Posts

Please tell me why I get a NaN returned in my Javascript from :-

IssuedValue = document.getElementById("IssuedValue").value;

OutstandingValue = document.getElementById("OutstandingValue").value;

document.getElementById("IssuedValue").value = IssuedValue + OutstandingValue;

 

document.getElementById("IssuedValue").value ends up being a NaN, why?

Link to comment
https://forums.phpfreaks.com/topic/48633-solved-javascript-returning-nan/
Share on other sites

Do you have a recommendation on how I should identify what these values are?

Those two values are ex a MSSQL database.

The web page calls Ajax to repopulate its fields by calling a PHP program. This step works fine.

Next step is when the user clicks an install button Ajax is again called which in turn calls a PHP script on the server to update the database and on return from the PHP to Ajax I wish to alter those two fields so that I can call a Javascript function to print the displayed data.

However at this point the data on the screen is what is going to happen and I need this to change(the database has been updated) to what has happened. IssuedValue needs to be updated to what was altered in the database.

BTW The database is reflecting the correct information. So now the only issue is to get the printout to reflect the correct data.

I have added an alert to the scenario giving the following:-

my Ajax as follows:-

function handleIssueTicketsResponse()

    {

    if(http.readyState == 4 && http.status == 200)

{

var IssuedValue = document.getElementById("IssuedValue").value;

var OutstandingValue =   document.getElementById("OutstandingValue").value;

alert("Before IssuedValue: "+IssuedValue+" OutstandingValue: "+OutstandingValue);

 

and the alert reports both IssuedValue as well as OutstandingValue as undefined.

Therefore the problem lies in the getElementById() but is the problem my use of getElementById() or is the problem in my definition of these fields in my web page. These fields are defined as:-

<div style="position:relative;" id="IssuedValue";><b>Issued value.</b></div>

<div style="position:relative;" id="OutstandingValue";><b>Outstanding value.</b></div>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.