Hello,
I am having problems with using AJAX to call information to my primary ASP page from a secondary asp page that brings in the data I want to display.
I'm having the onfocus event trigger the function show() to call in the data from the secondary asp page. However, when I click on the record in the list, nothing happens. The information is suppose to appear ni the div id = "div_id". Please help. I need the information in the secondary asp page to appear in the primary asp page.
Relevant part of primary asp page:
JavaScript (js) page
Here is the secondary asp page code.
Thanks.
I am having problems with using AJAX to call information to my primary ASP page from a secondary asp page that brings in the data I want to display.
I'm having the onfocus event trigger the function show() to call in the data from the secondary asp page. However, when I click on the record in the list, nothing happens. The information is suppose to appear ni the div id = "div_id". Please help. I need the information in the secondary asp page to appear in the primary asp page.
Relevant part of primary asp page:
Code:
<table width="786" height="215" border="0" cellspacing="0">
<tr>
<td width="183" height="213" align="center" valign="top">
<table width="183" height="196" border="0" cellspacing="0">
<tr>
<th height="27" bgcolor="#0099FF" align="center"> </th>
</tr>
<tr>
<th height="12" bgcolor="#0099FF" align="center">List Heading</th>
</tr>
<tr>
<td valign="top" align="center"><form id="form3" name="form3" method="get">
<select name="selectlist" size="10" id="list"onfocus="show(this.value)">
<%while not rsS.eof%>
<option id="<%=rsS("ID")%>"><%= rsS("Name") %></option>
<% rsS.movenext
wend%>
</select>
</form></td>
</tr>
</table>
</td>
<td width="486" valign="top"><table width="597" border="1" cellspacing="0">
<tr>
<th colspan="4" scope="col" bgcolor="#0099FF">Display Heading 1</th>
<th scope="col" bgcolor="#0099FF">Display Heading 2</th>
<tr>
<th width="9%" height="23" bgcolor="#0099FF"><em>Column1 Heading</em></th>
<th width="9%" bgcolor="#0099FF"><em><strong>Column2 Heading</strong></em></th>
<th width="30%" bgcolor="#0099FF"><em><strong>Column3 Heading</strong></em></th>
<th width="26%" bgcolor="#0099FF"><em><strong>Column4 Heading</strong></em></th>
<th width="26%" bgcolor="#0099FF"> </th>
</tr>
</table><div id="div_id"></div>
</td>
</tr>
</table>
JavaScript (js) page
Code:
// JavaScript Document
var xmlHttp
function show(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="primaryasppage.asp";
url=url+"?variable="+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("div_id").innerHTML=xmlHttp.responseText;
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
Code:
<%
Set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = "dsn=dsn;uid=user;pwd=pwd;database=db;"
rs.CursorType = 0
rs.CursorLocation = 3
rs.LockType = 1
rs.Source = ("Stored Procedure @SQLVariable= '" & request.QueryString("variable") & "'")
rs.Open()
%>
<% while not rs.eof%>
<% response.Write("<tr>") %>
<% response.Write("<td>") %><%= rs("column1") %><% response.Write("</td><td>")%><%= rs("column2") %><% response.Write("</td><td>")%><%= rs("column3") %> <% response.Write("</td><td>")%><%= rs("column4") %><% response.Write("</td><td> </td>")%>
<% response.Write("</tr>") %>
<% rs.movenext %>
<%wend%>
Comment