#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Norwich
    Posts
    53
    Rep Power
    11

    Angry Selecting a List menu


    Hi,

    I want to show one of two select list menus depending on the selection made on two citeria form a select list.

    e.g
    The queries statements are:

    <cfquery name="q_regiontown" datasource="bluegrass_property">
    SELECT townregionsearch, townorregionid
    FROM tbTownRegion
    ORDER BY townregionsearch ASC
    </cfquery>

    <cfquery name="q_region" datasource="bluegrass_property">
    SELECT DISTINCT region
    FROM dbo.tbregion
    ORDER BY region ASC
    </cfquery>


    <cfquery name="q_town" datasource="bluegrass_property">
    SELECT DISTINCT townname
    FROM dbo.tbtown
    ORDER BY townname ASC
    </cfquery>

    This list/menu has two options (search by town or region )and depending on which one the user selects will show either a region or a town select list/menu's (see below):



    <tr>
    <td>Town or Region </td>
    <td><select name="TownRegion" id="Townregion">
    <option value="value">Town or region</option>
    <cfoutput query="q_regiontown">
    <option value="#q_regiontown.townorregionid#">#q_regiontown.townregionsearch#</option>
    </cfoutput> </select></td>
    </tr>




    will select one of these two:

    I need a <cfif> here?

    <td>&nbsp;</td>
    <td><select name="select">
    <option value="value">Region</option>
    <cfoutput query="q_region">
    <option value="#q_region.region#">#q_region.region#</option>
    </cfoutput> </select></td>




    and a <cfelseif> here?

    <td>Town</td>
    <td><select name="ListTown" id="select2">
    <option value="value">Please select a town</option>
    <cfoutput query="q_town">
    <option value="#q_town.townname#">#q_town.townname#</option>
    </cfoutput>
    </select></td>


    Hope you can help

    Cheers

    peter
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,273
    Rep Power
    968
    Is this on 2 pages, or are you talking about doing this on a single page?

    If you want to do it on 2 pages, this is easy to do with CF. Just pass the choice from the first form to the target page, and based on that choice to display one or the other second dropdown box.

    If you want to do this on a single page, this isn't the realm of CF but of Javascript. You'll need to write event handlers to populate the second drop down box based on the selection the user makes in the first box. You can write your own, search the web for some premade solutions (www.javascripts.com might help) or even try out QForms (www.pengoworks.com).

IMN logo majestic logo threadwatch logo seochat tools logo