Click to See Complete Forum and Search --> : Passing variables using <SELECT> tag


ASPSQLVB
04-08-2008, 02:23 PM
I am trying to pass variables using the onchange event of the <SELECT> tag.

Calling a function using javascript that will then pass the variables from the select tag using the location.href is what I am trying to do.Thank you for your time.:)



function SendCampSessionId()
{
location.href=CarpCampEventNews.asp?CampSessionId=" + event.srcElement.parentElement.pk3 + "&CustomerId=" + event.srcElement.parentElement.pk2
}



<select NAME="CampSessions" SIZE="1" onchange=SendCampSessionId()>


<%
Dim k
Do Until RSCampSession.EOF

Response.Write("<option pk3='" & RSCampSession("CampSessionId") & "' & pk2='" & CustomerId & "'>") & RSCampSession("CampSession")

RSCampSession.MoveNext
Loop
%>


</select>

russell
04-08-2008, 05:11 PM
<script>
function SendCampSessionId()
{
url = "CarpCampEventNews.asp?CampSessionId=";
url += event.srcElement.options[event.srcElement.options.selectedIndex].pk3;
url += "&CustomerId=" + event.srcElement.options[event.srcElement.options.selectedIndex].pk2;
//alert (url);
location.href = url;
}
</script>

<select NAME="CampSessions" SIZE="1" onchange="SendCampSessionId()">
<option pk2="1" pk3="1">option 1
<option pk2="2" pk3="2">option 2
</select>

ASPSQLVB
04-08-2008, 07:10 PM
Problem Fixed!!!...Thank You Russell.:)