Thanks Randy!!!
This worked like a charm.
I'm not sure this gets said enough but this list is a
very good source of information.
Chris
--- "Ellis, Randy" <[EMAIL PROTECTED]> wrote:
> Here is a working solution I just created. If the
> code is not clear, email
> me with questions at [EMAIL PROTECTED]
>
> You will need to modify the code for your stored
> procedures and default
> values.
>
> <html>
> <head>
> <title>States and Counties</title>
>
> <SCRIPT LANGUAGE="JavaScript">
>
> // Load every county from every state
> <CFQUERY NAME="StatesCounties"
> DATASOURCE="StateCounty">
> SELECT CountyName, StateAbbr
> FROM Counties
> </CFQUERY>
>
> <CFINCLUDE template='/CFIDE/scripts/wddx.js'>
>
> // Convert the CF Query data into Javascript
> variables
> <CFWDDX ACTION='cfml2js' input=#StatesCounties#
> topLevelVariable='StatesCounties'>
>
> function ChangeCounties(STAbbr, CountyNm) {
>
> nRows = StatesCounties.getRowCount();
>
> var ctr = 0;
> for (row = 0; row < nRows; ++row) {
> if (STAbbr.value == StatesCounties.getField(row,
> 'StateAbbr')) {
> // Load the dropdown list with counties for the
> state selected
> CountyNm.options[ctr]=new
> Option(StatesCounties.getField(row,
> 'CountyName'),StatesCounties.getField(row,
> 'CountyName'));
> ctr++;
> }
> }
>
> return true;
>
> }
> </SCRIPT>
>
> </HEAD>
>
> <BODY>
>
> <CFQUERY NAME="States" DATASOURCE="StateCounty">
> Select StateName, StateAbbr
> From States
> Order By StateName
> </CFQUERY>
>
> <FORM>
>
> <SELECT NAME="STAbbr"
> ONCHANGE="ChangeCounties(this.form.STAbbr,
> this.form.CountyNm)">
> <OPTION VALUE="XX">Select State
> <CFOUTPUT QUERY="States">
> <OPTION
> VALUE="#States.StateAbbr#">#States.StateName#
> </CFOUTPUT>
> </SELECT>
>
> <SELECT NAME="CountyNm">
> <OPTION VALUE="None">Select County
> </SELECT>
>
> </FORM>
>
> </body>
> </html>
>
> Hope this helps,
> Randy Ellis
>
> -----Original Message-----
> From: Chris [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 15, 2001 2:47 PM
> To: KCFusion-List
> Subject: [KCFusion] dynamic dropdowns
>
>
>
> We are working on a page that involves a state drop
> down list and the counties in that state. We want
> to
> make it dynamic so when a user chooses Missouri,
> just
> the counties in Missouri are available.
>
> Here's what I got so far. On the onchange event for
> the state drop down we are setting a variable called
> favorite. If I declare an input whose name is
> favorite you can see this getting changed each time
> a
> new state is chosen. How do I go about setting up
> the
> stored procedure to accept this variable as an
> argument and reretrieve it each time the state is
> changed?
>
> I've included my attempt at this but I'm not having
> any luck.
>
> Thanks,
>
> Chris
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
> Transitional//EN">
>
> <html>
>
> <script language="JavaScript"
> type="text/javascript">
> function put()
> {
>
option=document.forms[0].st_ct.options[document.forms[0].st_ct.selectedIndex
> ].text
> txt=option
> document.forms[0].favorite.value=txt
> }
> </script>
>
> <!--- set up defaults for state and county --->
> <cfset ls_st_ct = "MO">
> <cfset li_county_num = 8>
>
> <cfstoredproc procedure="get_states"
> datasource="#application.glopds#"
> username="#application.glouser#"
> returncode="NO">
> <cfprocparam type="In"
> cfsqltype="CF_SQL_VARCHAR"
> dbvarname="@as_code_type"
> value="us_st_ct"
> null="No">
> <cfprocresult name="linkstate">
> </cfstoredproc>
>
> <body>
>
> <head>
> <title>Whatever</title>
> </head>
>
> <cfform name="detail">
> <table width="800" border="0" cellspacing="0"
> cellpadding="0">
> <tr>
> <td colspan="2">Test the state/county drop
> down</td>
> </tr>
> <tr>
> <!--- Set up the states drop down list --->
> <td>State:</td>
> <td><select name="st_ct" onchange="put()">
> <cfoutput query="linkstate">
> <option value= #linkstate.code_id#
> <cfif trim(ls_st_ct) eq
> #trim(linkstate.code_id)#>selected</cfif>>
>
> #linkstate.code_desc#</option>
> </cfoutput>
> </select>
> </td>
>
> <!--- Retrieve the county drop down list based off
> of the chosen state. --->
>
> <td>County:</td>
>
> <!--- <td><input name="favorite"
> value="Missouri"></td> --->
>
> <td><select name="favorite"
> onChange=<cfstoredproc
> procedure="county_num_name"
>
> datasource="#application.glopds#"
>
> username="#application.glouser#"
>
> returncode="NO">
>
> <cfprocparam
> type="In"
>
> cfsqltype="CF_SQL_CHAR"
>
> dbvarname="@as_st_ct"
>
=== message truncated ===
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
______________________________________________________________________
The KCFusion.org list and website is hosted by Humankind Systems, Inc.
List Archives........ http://www.mail-archive.com/cf-list@kcfusion.org
Questions, Comments or Glowing Praise.. mailto:[EMAIL PROTECTED]
To Subscribe.................... mailto:[EMAIL PROTECTED]
To Unsubscribe................ mailto:[EMAIL PROTECTED]