The below code will display two HTML SELECT boxes. When the user changes the first one when the page is loaded the second one gets populated with data which relates to what the user has selected.<br>
<br>
The Code works fine but I am now trying to put some finishing touches to it, and I have now blown the doors off.<br>
<br>
What I need to do is to take the rest of the data the user has placed on the form and send them back to same page via JS in a GET format. (thispage.asp?Category=5&Title=HELLO etc). The object passed into the JS function seems to be just the value of the selected option from the select box. How can I get to pass an object to JS which will allow me to work with the rest of the objects within the page ?<br>
<br>
I have only been fiddling with JS and VBS for a few weeks, so please let me know if I have missed the point.<br>
<br>
function GetSubCategoryList(Category) <br>
{<br>
this.location = "thispage.asp?Category=" + Category.value<br>
}<br>
<br>
<select name="Category" size="1" onChange="GetSubCategoryList(Category)" language="JavaScript"><br>
<br>
<% SQL = "Select Name,CategoryID From Category ORDER BY Name"<br>
<br>
RSCategory.Open SQL,Conn,1,2 <br>
Response.Write("<OPTION VALUE=0>") & vbcrlf<br>
Do While Not RSCategory.EOF <br>
if clng(RSCategory("CategoryID")) = clng(request.querystring("Category")) then<br>
Response.Write("<OPTION SELECTED VALUE=" & trim(RSCategory("CategoryID")) & ">" & RSCategory("Name")) & vbcrlf <br>
else<br>
Response.Write("<OPTION VALUE=" & trim(RSCategory ("CategoryID")) & ">" & RSCategory("Name")) & vbcrlf<br>
end if<br>
RSCategory.MoveNext<br>
Loop<br>
<br>
RSCategory.Close<br>
%> <br>
</select><br>
<br>
<select name="SubCategory" size="1"><br>
<br>
<% if request.querystring("Category") = "" and request.querystring("Category") = 0 then<br>
else<br>
SQL = "Select SubCategoryID , Name From SubCategory WHERE SubCategory.CategoryID = " & request.querystring("Category") & " ORDER BY Name" ' <br>
<br>
Response.Write("<OPTION>" & trim(SQL))<br>
RSCategory.Open SQL,Conn,1,2 <br>
Do While Not RSCategory.EOF<br>
Response.Write("<OPTION VALUE=" & RSCategory("SubCategoryID") & ">" & trim(RSCategory("Name"))) & vbcrlf<br>
RSCategory.MoveNext<br>
Loop<br>
<br>
RSCategory.Close<br>
Conn.Close<br>
end if<br>
%> <br>
</select>
<br>
The Code works fine but I am now trying to put some finishing touches to it, and I have now blown the doors off.<br>
<br>
What I need to do is to take the rest of the data the user has placed on the form and send them back to same page via JS in a GET format. (thispage.asp?Category=5&Title=HELLO etc). The object passed into the JS function seems to be just the value of the selected option from the select box. How can I get to pass an object to JS which will allow me to work with the rest of the objects within the page ?<br>
<br>
I have only been fiddling with JS and VBS for a few weeks, so please let me know if I have missed the point.<br>
<br>
function GetSubCategoryList(Category) <br>
{<br>
this.location = "thispage.asp?Category=" + Category.value<br>
}<br>
<br>
<select name="Category" size="1" onChange="GetSubCategoryList(Category)" language="JavaScript"><br>
<br>
<% SQL = "Select Name,CategoryID From Category ORDER BY Name"<br>
<br>
RSCategory.Open SQL,Conn,1,2 <br>
Response.Write("<OPTION VALUE=0>") & vbcrlf<br>
Do While Not RSCategory.EOF <br>
if clng(RSCategory("CategoryID")) = clng(request.querystring("Category")) then<br>
Response.Write("<OPTION SELECTED VALUE=" & trim(RSCategory("CategoryID")) & ">" & RSCategory("Name")) & vbcrlf <br>
else<br>
Response.Write("<OPTION VALUE=" & trim(RSCategory ("CategoryID")) & ">" & RSCategory("Name")) & vbcrlf<br>
end if<br>
RSCategory.MoveNext<br>
Loop<br>
<br>
RSCategory.Close<br>
%> <br>
</select><br>
<br>
<select name="SubCategory" size="1"><br>
<br>
<% if request.querystring("Category") = "" and request.querystring("Category") = 0 then<br>
else<br>
SQL = "Select SubCategoryID , Name From SubCategory WHERE SubCategory.CategoryID = " & request.querystring("Category") & " ORDER BY Name" ' <br>
<br>
Response.Write("<OPTION>" & trim(SQL))<br>
RSCategory.Open SQL,Conn,1,2 <br>
Do While Not RSCategory.EOF<br>
Response.Write("<OPTION VALUE=" & RSCategory("SubCategoryID") & ">" & trim(RSCategory("Name"))) & vbcrlf<br>
RSCategory.MoveNext<br>
Loop<br>
<br>
RSCategory.Close<br>
Conn.Close<br>
end if<br>
%> <br>
</select>