Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading recordsets into a drop down list with a conditional statement

Status
Not open for further replies.

jwpward

Programmer
Sep 5, 2003
45
GB
Hi

I've got two drop down lists in a form. One is for teamleaders and one is for the agents (members) of each team. I need the agent drop down to read in a recordset of agents according to the teamleader that has been selected. At present I've got different recordsets for each teamleader, but can't quite work out the VBScript syntax.

This is what i have for the agent drop down at the moment:

<select name="agent" style="width: 150px" id="agent" title="<%=(Academy_Agent_Recordset.Fields.Item("agent").Value)%>">
--------------not sure about this next line--------------------
<% If (document.form1.teamleader.value = "Academy") Then
While (NOT Academy_Agent_Recordset.EOF)
%>
<option value="<%=(Academy_Agent_Recordset.Fields.Item("agent").Value)%>"><%=(Academy_Agent_Recordset.Fields.Item("agent").Value)%></option>
<%
Academy_Agent_Recordset.MoveNext()
Wend
If (Academy_Agent_Recordset.CursorType > 0) Then
Academy_Agent_Recordset.MoveFirst
Else
Academy_Agent_Recordset.Requery
End If
'end of first if
End If
%>
</select>


I'm trying to read in the academy_agent_recordset when 'Academy' has been selected on the teamleader drop down. I think my first If statement is incorrect. I know how to write it in Javascript, but want to do it all in VBScript.

I hope this makes sense!

Thanks in advance.

 
You're confusing server-side and client-side. "document.form1.teamleader" doesn't exist until the browser renders the page - search the FAQs about dynamic select lists.

Another option is to create an array for each team leader and use the array to load the select list via javascript on the client-side

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

zen.gif

 
Thanks a lot for your reply. I've found some good information in other threads as you suggested.

Cheers

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top