Pass dropdown Item to session variable

C

carmen

I am using the code below to open another page depending on what is
selected. This is working ok but I would like to streamline it so that I
will hot have to create a page everytime a new category code is added. How
can I pass the category code to another page as a variable after it is
selected? That way I would only need one page that can be used for all
categories.

Thanks
Carmen

<select name="ListBoxURL" size="1" language="javascript"
onchange="gotoLink(this.form);">
<option selected>Open Report by Category Code
<%
While not rs.EOF
%>
<option
value="Action_Items/<%=rs("category_code")%>_start.asp"><%=rs.fields("category_code")%>
<%
rs.MoveNext
Wend
rs.Close
%>
</select>
</p>
<script language="JavaScript">
<!--
function gotoLink(form) {
var OptionIndex=form.ListBoxURL.selectedIndex;
parent.location = form.ListBoxURL.options[OptionIndex].value;}
//-->
</script>
 
R

Ray Costanzo [MVP]

So, wait, you have files named category1_start.asp, category2_start.asp, and
so on?

This is what ASP is meant to overcome. Pass the category ID to your page
and query the data accordingly.

<select onchange="location.href='display.asp?catid='+this.value;">
<% Do while not.....
<option
value="<%=rs("category_code")%>"><%=rs("category_code")%></option>

And then on display.asp

<%
Dim catID
catID = Request.Querystring("catid")
%>

And from there, query your database and get whatever it is you need to
display based on the category ID that was passed.

Ray at work



carmen said:
I am using the code below to open another page depending on what is
selected. This is working ok but I would like to streamline it so that I
will hot have to create a page everytime a new category code is added. How
can I pass the category code to another page as a variable after it is
selected? That way I would only need one page that can be used for all
categories.

Thanks
Carmen

<select name="ListBoxURL" size="1" language="javascript"
onchange="gotoLink(this.form);">
<option selected>Open Report by Category Code
<%
While not rs.EOF
%>
<option
value="Action_Items/ said:
<%
rs.MoveNext
Wend
rs.Close
%>
</select>
</p>
<script language="JavaScript">
<!--
function gotoLink(form) {
var OptionIndex=form.ListBoxURL.selectedIndex;
parent.location = form.ListBoxURL.options[OptionIndex].value;}
//-->
</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top