troubleshooting Question

Invoke cfquery for state/province retrieval when country selected on same page

Avatar of Ian White
Ian WhiteFlag for Australia asked on
Web ServersJavaScript
4 Comments2 Solutions432 ViewsLast Modified:
I have a coldfusion generated selection list that defaults a country selection according to visitor location.

Further down the page is a state/ province list with a select query with the country input from the country selected in the list above.

I want to pass the country to the  query depending on reselection of country so the appropriate states/provinces selection is selected further down the page without the user havin to leave the page.

Eg May arrive on page with Canada preselected but visitor may want to select USA , Australia etc.  

The dynamic/ select  input field is free format entry for countries without states,

Solution using ColdFusion6/  java script
Tip of page

<cfinclude template = "include_country_select_housaesit.cfm">

  <CFSWITCH EXPRESSION="#PassedCountry#">
  

	
 	<CFCASE Value="Australia,United States,Canada">
	
	    <cfif isDefined ("url.sta")
		and url.sta GT " ">
		
		<cfoutput>
		<CFSELECT Name="Crit1_Value" 
		Message="Please select State " 
		QUERY="GetStates"
		Size=1 
		Value="State"
		Selected = "#url.sta#"
		Display="State"
		Required="Yes">
		</CFSELECT>
		</cfoutput>
 	   
	   <cfelse>
	   
	    <CFSELECT Name="Crit1_Value" 
		Message="Please select State " 
		QUERY="GetStates"
		Size=1 
		Value="State"
		Display="State"
		Required="Yes">
		</CFSELECT>
		
		</cfif>
		
	</CFCASE>
	<CFDEFAULTCASE>
		<CFINPUT Type="Text" Name="Crit1_Value" 

		Maxlength="30"
		Size="20"  >
	</CFDEFAULTCASE>
	
</CFSWITCH>

Open in new window

ASKER CERTIFIED SOLUTION
Ian White
Owner and Founder

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros