Dynamic County List After State List

Posted on 2006-04-02
Last Modified: 2010-04-25

I have a form for user information.  I have a simple "enter your address" form
I am going to post the two <input> value's that i'm having trouble with
I want the form to reload without posting any information to my database once the state has been chosen and then a list of counties in that state will appear in that list.

Any help would be great!!!

Here is my state Dynamic List

<select name="State">
While (NOT Recordset3.EOF)
%><option value="<%=(Recordset3.Fields.Item("State").Value)%>" <%If (Not isNull((Recordset1.Fields.Item("State").Value))) Then If (CStr(Recordset3.Fields.Item("State").Value) = CStr((Recordset1.Fields.Item("State").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Recordset3.Fields.Item("State").Value)%></option>
If (Recordset3.CursorType > 0) Then
End If

The state is working OK
and here is what I have for county so far.  

<select name="County">
While (NOT Recordset4.EOF)
%><option value="<%=(Recordset4.Fields.Item("County").Value)%>" <%If (Not isNull((Recordset1.Fields.Item("County").Value))) Then If (CStr(Recordset4.Fields.Item("County").Value) = CStr((Recordset1.Fields.Item("County").Value))) Then Response.Write("selected=""selected""") : Response.Write("")%> ><%=(Recordset4.Fields.Item("County").Value)%></option>
If (Recordset4.CursorType > 0) Then
End If

Please let me know what I need to add to make this work.
Thanks, Austin
Question by:USCBigRed
    1 Comment
    LVL 25

    Accepted Solution

    Doing this in ASP is going to be tricky if you're not confident with the language.  This is because you'd need to get the first drop down to post back the form to the server when a new selection was made in the list.  The server would then populate the second drop down list.  The problem is that you'd have to differentiate to the server whether the form has actually been completely filled in and submitted by the user, or whether the first list had just been changed.
    If your county values are being pulled from a database, then you will probably have to use ASP to get the values.  However, I don't see this information changing very often (!), so I'd recommend using javascript to populate the list instead.  This also means you don't need to post back when a new state is chosen.

    Macromedia's official tutorial on how to do this is here,

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
    This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now