Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NodeValue returns null

Status
Not open for further replies.

Bharthi

Technical User
Feb 6, 2009
5
0
0
ZA
Hi,

I'm new to XML and Java Script, i have been tasked to maintain a web application for a client and basically all that was required was a changed to SQL stored proc's and functions. I have ammended the stored procs and functions and tried a simulation run of the system . i get to a point were i can print out a copy of the quote that i requested. This data is all stored in the DB and is 100% correct. I have checked my results with the Backend results and get a match of a 100%.QuoteID in the DB is set as an int throughout. In the Main.asp page the QuoteID is Declared as Var QuoteID. This main page calls a save.js page that has the actual error. The xml does not get created as the JS page errors with the following :
============================================================
An error occured while processing the XML Request.
"Error converting datatype nvarchar to int.
QuoteID - undefined.
'null' is null or not an object

==========================================================

function BuildMisc(ParentNode) {
alert('ParentNode = ' + ParentNode)
var oParentNode = oMainXML.getElementsByTagName(ParentNode).item(0)
var oXML = new ActiveXObject("Msxml2.DOMDocument.3.0")
var oChild = oXML.createElement('MESSAGEID')
alert(QuoteID) -> returns a value of 12345 as expected
oChild.text = QuoteID
oParentNode.appendChild(oChild)
var oChild = oXML.createElement('ACTIONTYPE')
oChild.text = "NB"
oParentNode.appendChild(oChild)
alert('text3')
var oChild = oXML.createElement('POLICY')
oParentNode.appendChild(oChild)
}
==========================================================
The QuoteID that is parsed to the oChild.text = "null" according to the error received. However i did an alert befor the variable was parsed to the oChild element to see if the value was lost. It reflected as expected. When the value is parsed to oChild.text it crashes when the appendChild funtion is used and the error is "null is null or not an object". Is there a way i can do an alert to see the actual value of the oChild after the command oChild.text = QuoteID ? Why does it crash at this point? This code was in use +-3 years back and worked perfectly? any suggestions is welcome as i am relatively new and do not know much at all about XML's and JScript.

NB: The alerts were inserted as a debugging tool to see actual point of failure
Thanks for any help in advance.



 
In the code QuoteId is assigned to oChild as below.
When i do an alert(oChild) after the below command and the program tries to append the xml the error is thrown.

oChild.text = QuoteID
 
have tried printing this

alert("CHILD=" + oChild) -- this prints an alert with just CHILD=

any suggestions?
 
no. i just need the node to be appended to the XML. Does the above code look incorrect in any way to you? As per the rest of the page the prgramming is pretty much the same.
 
me said:
Do you need to add the node before setting its contents?

you said:
no. i just need the node to be appended to the XML.

Which is exactly what I asked! Perhaps if I rephrase to be much more obvious:

What happens if you append the node before you try and set the text on it?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
that still gives the error null is null or not an object
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top