|
 |
aspx_beginners thread: Drop Down Listbox - Selected Item/Index
Message #1 by "Colin Wisdom" <colin_wisdom@h...> on Thu, 5 Jul 2001 16:44:35
|
|
I am trying to use a drop down list box to store a range of dates. I can
populate the list with no problem at all but I'm having real problems
identifying the list selected list item after the user changes it.
I have tried both the HTML listbox control and the webforms control, both
without success.
I am trying to access it by retrieving the SelectedItem and/or
SelectedIndex value, but it always seems to return the value for the
original item and not the newly selected item.
Any help would be priceless!!! :¬)
Many thanks,
Colin
Message #2 by "Paul" <ppp@h...> on Thu, 5 Jul 2001 12:20:17 -0400
|
|
Colin,
This is how I do it. I have a table full of clients and each client has 1
to n projects in a list box. I load the table and list box and then use the
java script functions to pull out the selected value and switch to a
different page using the selected values to load. I hope this helps in your
situation.
Paul
<script language="JavaScript">
function GetValue(x)
{
// var methods = window.document.clientList.projectKey;
// var method = methods.options[methods.selectedIndex].value;
alert(x)
var xxx
document.clientList.projectKey.options[document.clientList.projectKey.select
edIndex].value;
// var pkval = window.document.clientList.projectKey;
// var pk = pkval.options[pkval.selectedIndex].value;
alert(xxx);
}
</script>
<script language="JavaScript">
function ChgPage(x)
{
var select1 = eval("document.clientList.select_pname" + x)
var selValue1 = select1.value
document.clientList.ptext1.value = selValue1;
if (selValue1 != "Select Project Here")
{
document.clientList.submit();
}
return;
}
x = 0
Do While Not rstClient.EOF
%>
<tr>
<td>
<a
href='ClientUpdate1.asp?clientPK=<%=rstClient("clientPK")%>'><%=rstClient("c
ompany")%></a>
</td>
<td>
<a
href='ClientUpdate1.asp?clientPK=<%=rstClient("clientPK")%>'><%=rstClient("f
name") + " " + rstClient("lname") %></a>
</td>
<td>
<a href='NewProject1.asp?clientPK=<%=rstClient("clientPK")%>'><%varCPK
rstClient("clientPK")%><b>NP</b></a>
</td>
<form name=clientList method=post action='TestUpdateProject.asp'>
<%
'==============================================================
Set rstProject = Server.CreateObject("ADODB.Recordset")
varPSQL = "Select * from Project where clientPK=" & varCPK
rstProject.Open varPSQL, strSCSQLCon
If Not rstProject.EOF Then
%>
<td>
<select NAME=select_pname<%=x%> align=left STYLE="width:200; height:10"
onchange="ChgPage(<%=x%>)">
<option>Select Here
<%
Do While Not rstProject.EOF
%>
<option
VALUE="<%=rstProject("projpk")%>"><b><%=Trim(rstProject("pname"))%></b>
<%
rstProject.MoveNext
Loop
%>
</select>
</td>
<%
rstProject.Close
Set rstProject = Nothing
End If
'=============================================================
rstClient.MoveNext
x = x + 1
Loop
rstClient.Close
Set rstClient = Nothing
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxx
----- Original Message -----
From: "Colin Wisdom" <colin_wisdom@h...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Thursday, July 05, 2001 4:44 PM
Subject: [aspx_beginners] Drop Down Listbox - Selected Item/Index
> I am trying to use a drop down list box to store a range of dates. I can
> populate the list with no problem at all but I'm having real problems
> identifying the list selected list item after the user changes it.
>
> I have tried both the HTML listbox control and the webforms control, both
> without success.
>
> I am trying to access it by retrieving the SelectedItem and/or
> SelectedIndex value, but it always seems to return the value for the
> original item and not the newly selected item.
>
> Any help would be priceless!!! :¬)
>
> Many thanks,
>
> Colin
>
>
Message #3 by "Colin Wisdom" <colin_wisdom@h...> on Fri, 6 Jul 2001 10:39:35
|
|
Paul,
Many thanks for the advice, it was just what I was looking for!
Many thanks,
Colin
|
|
 |