|
-
dropdown list
I am having trouble with a dropdown list. I have a dropdownlist that updates another dropdown list. It does a refresh on the page and then the first dropdown list I select looses the value I selected..but the second dropdown list does retain the changes from the first. How do i give the first dropdown list that contains the OnChange() function back the value I selected? see code below...
<%
' variables
dim mytime
dim mySQL
dim accessdb
dim conntemp
dim rstemp
dim strconn
dim showblank
dim shownull
dim alldata
dim numcols
dim numrows
dim dropdown
dim SQL_dd
dim myrs
dim strClients
strClients = ""
mytime = Time
'on error resume next
accessdb=server.mappath("New Time sheet Tables.mdb")
strconn="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
strconn=strconn & accessDB & ";"
set conntemp=server.createobject("adodb.connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Set rs2 = Server.CreateObject("ADODB.Recordset")
Set rs3 = Server.CreateObject("ADODB.Recordset")
Set rs4 = Server.CreateObject("ADODB.Recordset")
conntemp.open strconn
%>
<%
'Get clientcode from querystring
strClients = Request.QueryString("CList")
mySQL_DL = "Select ClientCode From Clients2"
set rs=conntemp.Execute(mySQL_DL)
%>
<b>ClientCode:</b>
<select name="ClientList" size="1" ONCHANGE="HandleChange()">
<% Do While Not rs.EOF %>
<option value="<%= rs.Fields("ClientCode").Value %>"><%= rs.Fields("ClientCode").Value %></option>
<%
rs.MoveNext
Loop
rs.close
set rs=nothing
'This is where I tried to reset the dropdown list back to what i selected..
'For Each objOption in ClientList.Options
For i = 0 to ClientList.Items.Count -1
If ClientList.InnerText = strClients Then
ClientList.SelectedIndex = i
End If
Next
%>
</select>
<br>
<%
' I also tried this... it didn't work either....
'Dim i
'If value <> "" Then
' For i = 0 To ClientList.Items.Count - 1
' If ClientList.Items(i).Value = Request.QueryString("CList") Then
' ClientList.SelectedIndex = i
' End If
' Next
'End If
%>
<%
mySQL_DL = "Select Project From Projects"
set rs2=conntemp.Execute(mySQL_DL)
%>
<b>Project:</b>
<select name="ProjectList" size="1">
<% Do While Not rs2.EOF %>
<option value="<%= rs2.Fields("Project").Value %>"><%= rs2.Fields("Project").Value %></option>
<%
rs2.MoveNext
Loop
%>
</select>
<br>
<%
mySQL_DL = "Select Category From [Project Category]"
set rs3=conntemp.Execute(mySQL_DL)
%>
<b>Category:</b>
<select name="ProjectCategory" size="1">
<% Do While Not rs3.EOF %>
<option value="<%= rs3.Fields("Category").Value %>"><%= rs3.Fields("Category").Value %></option>
<%
rs3.MoveNext
Loop
%>
</select>
<br>
<b>Vendor:</b>
<select name="ProjectVendor" size="1">
<%
mySQL_DL = "Select VendorName, VendorID From Vendors Where ClientCode = '" & strClients & "'"
set rs4 = conntemp.Execute(mySQL_DL)
Do While Not rs4.EOF %>
<option value="<%= rs4.Fields("VendorName").Value %>"><%= rs4.Fields("VendorName").Value %> - <%= rs4.Fields("VendorID").Value %></option>
<%
rs4.MoveNext
Loop
%>
<option value=""></option>
</select>
<%
' close connection
'rs.close
'set rs=nothing
'rs2.close
'set rs2=nothing
'rs3.close
'set rs3=nothing
'rs4.close
'set rs4=nothing
conntemp.close
set conntemp=nothing
%>
</form>
<Script language="JavaScript">
function HandleChange()
{
box = document.TimeAlloc.ClientList;
//alert(box.selectedIndex);
mValue = box.options[box.selectedIndex].value;
//alert ("xx " + mValue + " xx");
window.location.href = "TimeAllocation.asp?CList=" + mValue ;
resetlist()
}
</Script>
Similar Threads
-
By Nelson in forum ASP.NET
Replies: 1
Last Post: 06-23-2003, 10:03 AM
-
By Jeff Johnson in forum .NET
Replies: 2
Last Post: 10-29-2002, 02:11 PM
-
By Rodney Hall in forum ASP.NET
Replies: 1
Last Post: 08-28-2002, 09:55 AM
-
By Larry Rebich in forum vb.announcements
Replies: 1
Last Post: 06-28-2001, 01:22 PM
-
Replies: 0
Last Post: 06-13-2000, 10:55 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks