First time in XML (XMLDOM Problems)


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: First time in XML (XMLDOM Problems)

  1. #1
    Join Date
    Feb 2005
    Posts
    1

    First time in XML (XMLDOM Problems)

    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 = "http://192.168.1.151/getdata.asp?fname=" &   _
                 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\wwwroot\test.mdb"
    	
    	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

  2. #2
    Join Date
    Feb 2005
    Posts
    4
    That Response.write sT line at the end of the function on the HTML page looks like it shouldn't be there. Also, you might try creating a <div> or <span> and setting the .innerText property of those instead of using document.write() statements.

    Is there any reason you're using the "Microsoft.XMLDOM" progID? I've been using "MSXML2.DOMDocument.3.0" and having really good results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center