cookmyster
asked on
Populating DropDowns from A Database
Okay here is my question... I have four drop down boxes that will be populated from a database. But I want them to change based on what one dropdown is showing... ex
Drop down 1 - Region (north america, south america)
Drop down 2 - Country (US, CAN)
Drop Down 3 - SubRegion (MidWest, West, SouthEast)
Drop Down 4 - States (New York, Maine, California)
So when I change the country drop down to US, it should only list the US States.... I was told that I could use javascript and arrays??? but I am not really sure... any ideas out there... here is the code I have so far...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--- This gets the function from the lookup table --->
<cfx_ingres name="functions" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'function'">
<!--- This populates the regiongroup dropdown box --->
<cfx_ingres name="getregiongroup" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'regiongroup'">
<!--- This populates the country dropdown box --->
<cfx_ingres name="getcountry" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'country'">
<!--- This populates the subregion dropdown box --->
<cfx_ingres name="getsubregion" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'region'">
<!--- This populates the state dropdown box --->
<cfx_ingres name="getstate" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'state'">
<html>
<head>
<title></title>
<!--- This calls the style sheet --->
<cfinclude template="template/style.c ss">
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="1000">
<tr>
<cfoutput>
<td colspan="#functions.record count#" bgcolor="##42637a" height="22" width="1000" nowrap>
<b> <font size="3" color="##ffcc99">#region# Regional Processing Center</font></b>
</td>
</cfoutput>
</tr>
<tr>
<cfoutput>
<td bgcolor="##133e47" colspan="#functions.record count#">
<b> <font color="##ffffff" size="3">#state#</font></b >
</td>
</cfoutput>
</tr>
<tr>
<td valign="top">
<table border="0" cellpadding="0" cellspacing="3">
<tr>
<td height="160">
<cfoutput><IMG src="images/states/#state# .gif"></cf output>
</td>
</tr>
<tr>
<td>
Sort By:
</td>
</tr>
<form name="form">
<tr>
<td>
<select name="selregiongroup" style="HEIGHT: 15px; WIDTH: 122px">
<cfoutput query="getregiongroup">
<option selected>#pcl_value#</opti on>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>
<select name="country" style="HEIGHT: 22px; WIDTH: 122px">
<cfoutput><option selected>#country#<option> </cfoutput >
<cfoutput query="getcountry">
<option value="#pcl_value#">#pcl_v alue#</opt ion>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>
<select name="selsubregion" style="HEIGHT: 22px; WIDTH: 122px">
<cfoutput><option selected>#region#</option> </cfoutput >
<cfoutput query="getsubregion">
<option>#pcl_value#</optio n>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>
<select name="state">
<cfoutput><option selected>#state#</option>< /cfoutput>
<cfoutput query="getstate">
<option value="#pcl_value#">#pcl_v alue#</opt ion>
</cfoutput>
</select>
</td>
</tr>
</form>
</table>
</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="1000">
<cfoutput query="functions">
<tr>
<td bgcolor="##ffcc99" colspan="3">
<b>#functions.pcl_value#</ b>
</td>
</tr>
<CFX_INGRES sql="select pcd_pmfkey, pcd_function from pc_details where pcd_regiongroup = '#regiongroup#' and pcd_country = '#country#' and pcd_region = '#region#' and pcd_state = '#state#' and pcd_function = '#Functions.pcl_value#' order by pcd_function" db="dbmsu99::gis" name="pcdinfo">
<cfloop query="pcdinfo">
<!--- To check if there is no info available --->
<cfif pcdinfo.pcd_pmfkey is "" or pcdinfo.pcd_pmfkey is 0>
<tr BGCOLOR=###IIF(pcdinfo.cur rentrow MOD 2, DE ('dceaf3'), DE ('bbcbd5'))#>
<td colspan="#functions.record count#" align="middle">
No Information Is Available At This Time &nbs p; &n bsp; &nbs p;No Information Is Available At This Time
</td>
</tr>
<cfelse>
<tr BGCOLOR=###IIF(pcdinfo.cur rentrow MOD 2, DE ('dceaf3'), DE ('bbcbd5'))#>
<!--- This gets the employess name --->
<CFX_INGRES sql="select first, last from employee where pmf_key = '#pcd_pmfkey#'" db="cainfo::cainfo" name="empinfo">
<cfloop query="empinfo">
<td>
#first# #last#
</td>
</cfloop>
<!--- This gets the employess phone number --->
<CFX_INGRES sql="select * from phone_exts where pmf_key = '#pcd_pmfkey#'" db="cainfo::cainfo" name="phoneinfo">
<cfloop query="phoneinfo">
<td>
#phoneinfo.phone#
</td>
</cfloop>
<!--- This gets the employees email --->
<td>
<A href="mailto:#pcdinfo.pcd_ pmfkey#@ca i.com"><cf loop query="empinfo">#empinfo.f irst#.#emp info.last# @ca.com</C FLOOP></a>
</td>
</tr>
</cfif>
</cfloop>
<!--- Leaves a blank space between functions --->
<tr>
<td>
</td>
</tr>
</cfoutput>
</table>
</td>
</tr>
</table>
</body>
</html>
Drop down 1 - Region (north america, south america)
Drop down 2 - Country (US, CAN)
Drop Down 3 - SubRegion (MidWest, West, SouthEast)
Drop Down 4 - States (New York, Maine, California)
So when I change the country drop down to US, it should only list the US States.... I was told that I could use javascript and arrays??? but I am not really sure... any ideas out there... here is the code I have so far...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--- This gets the function from the lookup table --->
<cfx_ingres name="functions" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'function'">
<!--- This populates the regiongroup dropdown box --->
<cfx_ingres name="getregiongroup" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'regiongroup'">
<!--- This populates the country dropdown box --->
<cfx_ingres name="getcountry" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'country'">
<!--- This populates the subregion dropdown box --->
<cfx_ingres name="getsubregion" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'region'">
<!--- This populates the state dropdown box --->
<cfx_ingres name="getstate" db="dbmsu99::gis" sql="select pcl_value from pc_lookup where pcl_type = 'state'">
<html>
<head>
<title></title>
<!--- This calls the style sheet --->
<cfinclude template="template/style.c
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="1000">
<tr>
<cfoutput>
<td colspan="#functions.record
<b> <font size="3" color="##ffcc99">#region# Regional Processing Center</font></b>
</td>
</cfoutput>
</tr>
<tr>
<cfoutput>
<td bgcolor="##133e47" colspan="#functions.record
<b> <font color="##ffffff" size="3">#state#</font></b
</td>
</cfoutput>
</tr>
<tr>
<td valign="top">
<table border="0" cellpadding="0" cellspacing="3">
<tr>
<td height="160">
<cfoutput><IMG src="images/states/#state#
</td>
</tr>
<tr>
<td>
Sort By:
</td>
</tr>
<form name="form">
<tr>
<td>
<select name="selregiongroup" style="HEIGHT: 15px; WIDTH: 122px">
<cfoutput query="getregiongroup">
<option selected>#pcl_value#</opti
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>
<select name="country" style="HEIGHT: 22px; WIDTH: 122px">
<cfoutput><option selected>#country#<option>
<cfoutput query="getcountry">
<option value="#pcl_value#">#pcl_v
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>
<select name="selsubregion" style="HEIGHT: 22px; WIDTH: 122px">
<cfoutput><option selected>#region#</option>
<cfoutput query="getsubregion">
<option>#pcl_value#</optio
</cfoutput>
</select>
</td>
</tr>
<tr>
<td>
<select name="state">
<cfoutput><option selected>#state#</option><
<cfoutput query="getstate">
<option value="#pcl_value#">#pcl_v
</cfoutput>
</select>
</td>
</tr>
</form>
</table>
</td>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="1000">
<cfoutput query="functions">
<tr>
<td bgcolor="##ffcc99" colspan="3">
<b>#functions.pcl_value#</
</td>
</tr>
<CFX_INGRES sql="select pcd_pmfkey, pcd_function from pc_details where pcd_regiongroup = '#regiongroup#' and pcd_country = '#country#' and pcd_region = '#region#' and pcd_state = '#state#' and pcd_function = '#Functions.pcl_value#' order by pcd_function" db="dbmsu99::gis" name="pcdinfo">
<cfloop query="pcdinfo">
<!--- To check if there is no info available --->
<cfif pcdinfo.pcd_pmfkey is "" or pcdinfo.pcd_pmfkey is 0>
<tr BGCOLOR=###IIF(pcdinfo.cur
<td colspan="#functions.record
No Information Is Available At This Time &nbs
</td>
</tr>
<cfelse>
<tr BGCOLOR=###IIF(pcdinfo.cur
<!--- This gets the employess name --->
<CFX_INGRES sql="select first, last from employee where pmf_key = '#pcd_pmfkey#'" db="cainfo::cainfo" name="empinfo">
<cfloop query="empinfo">
<td>
#first# #last#
</td>
</cfloop>
<!--- This gets the employess phone number --->
<CFX_INGRES sql="select * from phone_exts where pmf_key = '#pcd_pmfkey#'" db="cainfo::cainfo" name="phoneinfo">
<cfloop query="phoneinfo">
<td>
#phoneinfo.phone#
</td>
</cfloop>
<!--- This gets the employees email --->
<td>
<A href="mailto:#pcdinfo.pcd_
</td>
</tr>
</cfif>
</cfloop>
<!--- Leaves a blank space between functions --->
<tr>
<td>
</td>
</tr>
</cfoutput>
</table>
</td>
</tr>
</table>
</body>
</html>
Refer to :
http://developer.irt.org/script/form.htm#4
for the JS code to create dynamic drop down menus...
CJ
http://developer.irt.org/script/form.htm#4
for the JS code to create dynamic drop down menus...
CJ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i can give u this code in asp
if u want
jimmy
if u want
jimmy
ASKER
I did it using <cfif isdefined> and lots of them
i have got a custom tag threeselectsrelated.cfm which will solve ur problem
mail me at jimmy_282@yahoo.com
i will send u the tag.
jimmy
mail me at jimmy_282@yahoo.com
i will send u the tag.
jimmy
cookmyster: Any progress?
cookmyster: Any progress?
Dont you guys hate it when they offer up 100 points and then just dont come back after getting theyre answer
Doug
Doug
ASKER
I hate that more than anyone also.... I apologize for this... that project I was working for this question was put on hold, I am sorry about that... but I should be on by the end of the week and the points will be awarded to the right person.. again.. I am sorry for this...
Rich
Rich
ASKER
Thx for help ccress... sorry for the delay...
http://devex.allaire.com/developer/gallery/SearchResults.cfm?keywords=ThreeSelectsRelated+&search=search
And that is a custom tag that would just that, but not with 4