Ajax

Can anyone please advise why this wont work ? The fisrt page of code reads
data from a database and populates combobox, depending on the selection made
the second combobox can be poputated, but the second procedure
(select_via_ajax_include.asp ) does not return the variables in the function
call ajaxcombo(sql, selectobjID, loadarea), can anyone advise ?

<%
Dim range
Dim range_numRows

set cn=Server.CreateObject("ADODB.Connection")
cn.Open "Provider=SQLOLEDB.1;Password=glencoe;Persist Security
Info=True;User ID=qadmin;Initial Catalog=UserInfo;Data Source=TLGUKSP17"
Set range=Server.CreateObject("ADODB.Recordset")
range.ActiveConnection=cn
range.Source="SELECT Range FROM [Variance Matrix] GROUP BY Range ORDER BY
Range"
range.CursorType=0
range.CursorLocation=2
range.LockType=1
range.Open()

range_numRows=0

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www/w3/org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Variance Selector</title>
<script type="text/javascript">
var loadobjects=""
var rootdomain="http://" + window.location.hostname

function ajaxpage(url,containerid)
{
var page_request=false
if (window.XMLHttpRequest)
page_request=new XMLHttpRequest()
else if (window.ActiveXObject) {
try
{
page_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try {
page_request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e) {}
}
}
else
return false
page_request.onreadystatechange=function()
{
loadpage(page_request, containerid)
}

page_request.open('GET', url, true)
page_request.send(null)
}


function loadpage(page_request,containerid)
{
if (page_request.readystate == 4 && (page_request.status= 0 ||
window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request. responseText
}

function loadobjs()
{
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++) {
var file=arguments[i]
var fileref=""
if (loadobjects.indexOf(file) == -1) {
if (file.indexOf(".js") != -1) {
fileref=document.createElement("script")
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src",file);
}
else if (file.indexOf(".css") != -1) {
fileref=document.createElement("link")
fileref.setAttribute("rel","stylesheet");
fileref.setAttribute("type","text/css");
fileref.setAttribute("href",file);
}
}
if (fileref != "") {
document.getElementsByTagName("head").item(0).appendChild(fi leref)
loadedobjects+=file+" "
}
}
}

function ajaxcombo(sql, selectobjID, loadarea)
{
var selectobj=document.getElementById? document.getElementById(selectobjID)
: ""
alert ('here again ' + sql)
if (selectobj != "" && selectobj.options[selectobj.selectedIndex].value !=
"")
sql=sql + "'" + selectobj.options[selectobj.selectedIndex].value + "'"
var walker=document.getElementsByTagName("span")
var newRange=''
for (var i=0; i<walker.length; i++)
{
var theName=walker[i].id
if (theName == loadarea)
{
newRange=walker[i+1].id
}
}
ajaxpage('select_via_ajax_include.asp?sql=' + sql + '&range=' + loadarea +
'&NewRange=' + newRange, loadarea)
}

</script>
</head>
<body>
<form name="form1" method="get" action="/select_via_ajax_include.asp">
<p>
<select name="sel_man" id="sel_man" onchange="(this.selectedIndex!=0)?
ajaxcombo('sp_Product ','sel_man', 'Product') : alert('Please choose a
Range'); return false">

<option value="0">Choose Range</option>
<%
while (not range.eof)
%>
<option value="<%= range.fields.Item("Range")%>" > <%=
range.fields.Item("Range")%></option>
<%
range.movenext
wend
if (range.Cursortype > 0) then
range.MoveFirst
else
range.requery
end if
%>
</select>

<span id="Product">
<select name="dummy_select" disabled>
<option>Choose Product</option>
</select>
</span>


<span id="lamptype">
<select name="dummy_select" disabled>
<option>Choose Lamp Type</option>
</select>
</span>


<span id="lamps">
<select name="dummy_select" disabled>
<option>Choose Lamp Quantity</option>
</select>
</span>


<span id="watts">
<select name="dummy_select" disabled>
<option>Choose Wattage</option>
</select>
</span>


<span id="gear1">
<select name="dummy_select" disabled>
<option>Choose E3/Std</option>
</select>
</span>


<span id="gear1">
<select name="dummy_select" disabled>
<option>Choose Gear Type</option>
</select>
</span>
</p>

<p>

<span id="sapcode">
<input type='text' id='material_desc' size='10'>
</span>


<span id="matdesc">
<input type='text' id='material_desc' size='100'>
</span>
</p>

</form>
</body>
</html>

<%range.close
set range=nothing%>

*************** select_via_ajax_include.asp *************
<%
set cn=Server.CreateObject("ADODB.Connection")
cn.Open "Provider=SQLOLEDB.1;Password=glencoe;Persist Security
Info=True;User ID=qadmin;Initial Catalog=UserInfo;Data Source=TLGUKSP17"

Dim Product
dim ProductnumRows
Dim Rnge
Dim newrange

Rnge=request.querystring("range")
newrange=request.querystring("newrange")

set Product=Server.CreateObject("ADODB.Recordset")

Product.Open "exec " & replace(request.querystring("sql"),"%20"," ") , cn
Product_numRows=0

%>
<select name ='<%= Rnge%>' id='<%= Rnge%>' onchange="(this.selectedIndex
!=0)? ajaxcombo('sp_' + '<%= newrange%>','<%= Rnge%>','<%= newrange%>') :
alert('Please choose a ' + '<%= Rnge%>'); return false">

<option value="0">Choose <%= Rnge%></option>

<% While (NOT product.eof) %>
<option value="<%= product.fields.item(0).value%>"><%=
product.fields.item(0).value%></option>
<%
product.movenext
wend
if (product.cursortype>0) then
product.movefirst
else
product.requery
end if
%>
</select>
<%
product.close
set product=nothing
%>

Regards

John
John Peach [ Mo, 16 Juli 2007 16:17 ] [ ID #1770018 ]

Re: Ajax

"John Peach" <john.peach [at] zen.co.uk> wrote in message
news:469b7e3a$0$24747$da0feed9 [at] news.zen.co.uk...

> cn.Open "Provider=SQLOLEDB.1;Password=glencoe;Persist Security

Right now would be a good time to change your database password.

--
Bob Milutinovic
Cognicom - "Australia's Web Presence Specialists"
http://www.cognicom.net.au/
telephone (0417) 45-77-66
facsimile (02) 9824-2240
Bob Milutinovic [ Mo, 16 Juli 2007 19:26 ] [ ID #1770021 ]

Re: Ajax

Mr. Peach, your sooo fired.

"Bob Milutinovic" wrote:

> "John Peach" <john.peach [at] zen.co.uk> wrote in message
> news:469b7e3a$0$24747$da0feed9 [at] news.zen.co.uk...
>
> > cn.Open "Provider=SQLOLEDB.1;Password=glencoe;Persist Security
>
> Right now would be a good time to change your database password.
>
> --
> Bob Milutinovic
> Cognicom - "Australia's Web Presence Specialists"
> http://www.cognicom.net.au/
> telephone (0417) 45-77-66
> facsimile (02) 9824-2240
>
>
>
MightyMouse [ Di, 17 Juli 2007 18:10 ] [ ID #1771083 ]
Webserver » microsoft.public.inetserver.asp.general » Ajax

Vorheriges Thema: Don't submit form on Enter button
Nächstes Thema: Microsoft.XMLHTTP