I.odine 0 Newbie Poster

Hey Guys - I am trying to figure this out, but its doing my head in...

I basically have followed this: http://www.w3schools.com/Ajax/ajax_xmlfile.asp

to get a drop down list to populate from an XMl file, and when an option is selected a run down of all the nodes in that set are printed. works fine!

Now what I am trying to do is...when an option is selected from the DDL instead of just response.write() i was hoping to have it fill in the values to some textboxes i have in my form already on the page. I am having a hard time though, as the final step that seems to do the actual writing is a seperate .asp page, and i have NO idea how to get it to access the elements on the form...PHP is not an option at this time, so asp seems to be all I can use.

below is the code: (all available @ the link as well)

code for drop down list that calls the fuction in selectposting.js

positions.Attributes.Add("onchange", "showjob(this.options[this.selectedIndex].value)")

Selectposting.js - function for dropdownlist "onChange"

var xmlhttp  
  
function showjob(str)  
{  
xmlhttp=GetXmlHttpObject();  
if (xmlhttp==null)  
  {  
  alert ("Your browser does not support AJAX!");  
  return;  
  }  
var url="getjob.asp";  
url=url+"?q="+str;  
url=url+"&sid="+Math.random();  
xmlhttp.onreadystatechange=stateChanged;  
xmlhttp.open("GET",url,true);  
xmlhttp.send(null);  
}  
  
function stateChanged()  
{  
if (xmlhttp.readyState==4)  
{  
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;  
}  
}  
  
function GetXmlHttpObject()  
{  
if (window.XMLHttpRequest)  
  {  
  // code for IE7+, Firefox, Chrome, Opera, Safari  
  return new XMLHttpRequest();  
  }  
if (window.ActiveXObject)  
  {  
  // code for IE6, IE5  
  return new ActiveXObject("Microsoft.XMLHTTP");  
  }  
return null;  
}

getjob.asp

<%  
response.expires=-1  
q=request.querystring("q")  
  
set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")  
xmlDoc.async="false"  
xmlDoc.load(Server.MapPath("availablepositions.xml"))  
  
set nodes=xmlDoc.selectNodes("rss/channel/item[title='" & q & "']")  
  
  
for each x in nodes  
  for each y in x.childnodes  
    response.write("<b>" & y.nodename & ":</b> ")  
    response.write(y.text)  
    response.write("<br />")  
  next  
next  
%>

So if anyone knows how i could do this...i would be VERY appreciative!

Thank you in advance!

-][-

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.