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
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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.