I have just been working on a question with hielo (
https://www.experts-exchange.com/questions/25196926/jquery-related-selects-drop-down-menus-in-ASP-classic.html?anchorAnswerId=26832665#a26832665) which has now been resolved.
Basically my script has three linked drop down select boxes, these pull from three tables (depts, cat, subcats) all related with ID numbers
The state its in at the momement is working perfectly for example if i wanted to add a new product (ie. there there are no pre-defined values for the dept, cat or subcat)
my new question (this one!) it how can i now pass values which i can set as variables in asp such as
<%
deptID = RS("intDepartmentID")
catID = RS("intCategoryID")
subcatID = RS("intSubCategoryID")
%>
to my data processor page (which returns the values needed for the drop downs) so that if there is a variable set, it does a response.write on the option group and when you view the webpage, it pre-selects that option.
The code is as follows:
index.asp:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--#include virtual="/common/includes/
analytics.
asp"-->
<!--#include virtual="/common/includes/
functions.
asp"-->
<!--#include virtual="/common/includes/
personalis
ation.asp"
-->
<!--#include virtual="/common/includes/
connection
_string.as
p"-->
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery Related Selects</title>
<script src="/common/jQuery/jquery
-1.4.2.min
.js" type="text/javascript"></s
cript>
<script src="/common/jQuery/plugin
s/related-
selects/jq
uery.relat
edselects.
min.js" type="text/javascript"></s
cript>
<style type="text/css">
body { font:12px helvetica, arial, sans-serif; }
</style>
<script type="text/javascript">
$(function(){
$("#depts").relatedSelects
({
onChangeLoad: 'datasupplier.asp',
dataType: 'html',
selects: ['deptID', 'catID', 'subcatID']
});
});
</script>
</head>
<body>
<h1>jQuery Related Selects Plugin</h1>
<h2>Example</h2>
<form id="depts" method="post" action="/common/jQuery/plu
gins/relat
ed-selects
/results.a
sp">
<%
Set RSdept = Server.CreateObject("ADODB
.Recordset
")
SQLdept = "SELECT * FROM tblCategoryDepartments WHERE intWebDepartment = 1 AND intActive = 1 ORDER BY txtDepartmentName"
RSdept.OPEN SQLdept,Connection,3,3
%>
<select name="deptID">
<option value="">Choose Dept »</option>
<% Do While Not RSDept.EOF %>
<option value="<% =RSdept("intDepartmentID")
%>"><% =RSdept("txtDepartmentName
") %></option>
<%
RSDept.MoveNext
Loop
%>
</select>
<%
RSdept.Close
Set RSdept = Nothing
SQLdept = ""
%>
<select name="catID">
<option value="">Choose Category »</option>
</select>
<select name="subcatID">
<option value="">Choose SubCategory »</option>
</select>
<input name="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
datasupplier.asp:
<!--#include virtual="/common/includes/
functions.
asp"-->
<!--#include virtual="/common/includes/
personalis
ation.asp"
-->
<!--#include virtual="/common/includes/
connection
_string.as
p"-->
<%
If ""<>Trim(Request("catID"))
Then
SQL = "SELECT intSubCategoryID, txtCategoryName FROM tblProductSubCategories WHERE intMasterCategoryID = " & Request("catID") & " AND intWebCategory = 1 AND intActive = 1 ORDER BY txtCategoryName"
ELSEIF ""<>Trim(Request("deptID")
) Then
SQL = "SELECT intCategoryID, txtCategoryName FROM tblProductCategories WHERE intDepartmentID = " & Request("deptID") & " AND intWebCategory = 1 AND intActive = 1 ORDER BY txtCategoryName"
END IF
Set RS = Server.CreateObject("ADODB
.Recordset
")
RS.Open SQL,Connection,1,3
Do While Not RS.EOF
%>
<option value="<%=RS.Fields(0).val
ue %>"><% =RS.Fields(1).value %></option>
<%
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
%>
The idea being that with in the Do While Not RS.EOF loop in datasupplier.asp:
IF RS.Fields(0) = catID THEN Response.Write "selected"
does anyone have an idea about how to achive this?
thanks