There are several ways to go about this, easiest would be using either the
twoselectsrelated or activeselect custom tags, the drawback being that you
would have to select all of the states and all of the counties out of the
database into a specificly structured recordset to be used by the tags.
Also, load time is sometimes an issue with either of these custom tags.

Another way would be to put your page in a frameset
with the main frame being your form, and a 1 pixel frame being a processing
page.
you would then have an on change on the first select that sends the value to
the processing page through form submission, which runs the stored proc and
populates the second select box.

This works very well, but is more difficult to code

as far as running your stored proc on the same page after the page has been
sent to the browser, it isn't going to happen unless the page is re
rendered, and you probably should stay away from that route.  ColdFusion
code is processed server side, so it won't be able to interact with the page
the way you are asking. 

If you need some assistance with the frame method, I can give it to you,
otherwise the 2 custom tags are available on the developers exchange.

 >-----Original Message-----
 >From:         Chris[[EMAIL PROTECTED]]
 >Date:         Wednesday, May 16, 2001  11:17 AM
 >To:           KCFusion-List[[EMAIL PROTECTED]]
 >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.selectedI
 >ndex].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"
 >                                                      value=form.favorite
 >                                                      null="No">
 >
 >
<cfprocresult name="linkcounty">
 >
</cfstoredproc>  >
 >

 >                                                              <cfoutput
query="linkcounty">
 >
<option value= #linkcounty.county_num# 
 >
<cfif li_county_num eq
 >#linkcounty.county_num#>selected</cfif>>
 >
#linkcounty.county_name#
 >
</option>
 >
</cfoutput>
 >                              </select>
 >              </td>
 >      </tr>
 ></table>
 ></cfform>
 >                      
 ></body>
 ></html>
 >
 >
 >
 >__________________________________________________
 >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]
 > 
 >


 
 
______________________________________________________________________
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]
 

Reply via email to