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

Reply via email to