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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First time in XML (XMLDOM Problems)

Status
Not open for further replies.

Kinara

Programmer
Feb 23, 2005
2
US
Hi this is my first post here, and this is my first time using XML, what got me to use XML was to refresh a portion of my webpage without refreshing the whole page. What I'm trying to do is for a user to Enter its FirstName and Lastname on a .html document and then I want to send this data to a .asp document which looks up the record in a database and then I want to display them on the .html document.

This is the code for the .htm document

Code:
<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>

<SCRIPT LANGUAGE = "VBSCRIPT">

Function fxsearch()
             'msgbox("Hello" & " " & lname.value & ", " & fname.value)
            ' testing to see if the function is even being called on the click event
	' it works until here

             dim root
	dim source		
	dim x					
	dim passpara			
	dim sT
	
	passpara = "[URL unfurl="true"]http://192.168.1.151/getdata.asp?fname="[/URL] &   _
             fname.value & "&lname=" & lname.value
	
	source = CreateObject("Microsoft.XMLDOM")
	source.async = false
	source.load(passpara)
	
	root = source.documentElement
	
'	for each x in source.documentElement.childNodes
'		document.write("<b>" & x.nodename & "</b>")
'		document.write(": ")
'		document.write(x.text)
'		document.write("<br>")
'	next	

Response.write sT
		
End Function
	
</script>

<BODY>

<P>First Name : <INPUT id=fname name=""><BR>Last 
Name&nbsp;:&nbsp;<INPUT id=lname name=""></P>
<P><INPUT id=button1 style="LEFT: 9px; TOP: 82px" type=button value="Look Up!" onclick="fxsearch()" name=button1></P>

</BODY>
</HTML>

This is the code for the .asp document


Code:
<%@ Language=VBScript %>

<%
	dim conn
	dim rs
	dim strsql1
	dim fname
	dim lname
	
	fname = Request("fname")
	lname = Request("lname")
	
	set conn = server.CreateObject("ADODB.Connection")
	conn.Provider = "Microsoft.Jet.OLEDB.4.0"
	conn.Open = "C:\Inetpub\[URL unfurl="true"]wwwroot\test.mdb"[/URL]
	
	strsql = "Select * from name where firstname ='" & fname &  _
                        "' and lastname = '" & lname & "'"
	
	set rs = server.CreateObject("ADODB.Recordset")
	rs.Open(strsql,conn)
	
	sT = sT & "<tableofnames>" & vbcrlf
	
	do while not rs.EOF
		sT = sT & "<name>" & vbcrlf
		sT = sT & "<fname>" & rs("firstname") & "</fname>"
		sT = sT & "<lname>" & rs("lastname") & "</lname>"
		sT = sT & "</name>"

		rs.MoveNext
	loop

	sT = sT & "</tableofnames>" 


Response.Write sT

rs.Close
set rs = nothing

conn.Close
set conn = nothing

%>

What am I doing wrong? this is my first venture in XML I read alot of articles about the XMLHTTP and XMLDOM, but couldn't quite figure it out, I would greatly appreciate all the help.

Thanx

Kinara
 
You can't do what you are trying to do.
Code:
source.load(passpara)
passpara should be a reference to an XML file. You are sending it a reference to an ASP file. The ASP cannot be run, because that happens server-side. You are using code that is run only on the client.
 
Actually I got it working, thanx for the help, I used the XMLHTTP object to send stuff to an asp page, the asp page gets the results from the database and then I do a response.write which writes in XML format and then I use the XMLDOM object on the client page to populate my combo box with the results.

Kinara
 
Was about to reply and say you could do it! Didn't know about XMLHTTP, but have just read about it. I always thought you should be able to do it - and you can. Thanks for the post, you have opened my eyes to new possibilities.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top