Sunday 15 February 2015

drop down menu - populating select based on previous select - how to run the query after selection -


I am running Coldfusion 10,08,284032 with SQL Server 2012 as the data source of Windows Server 2008 R2 datacenter On.

I want to make two choices on a form. The name of wildlife conservation and the second, which lists the trails preserved after being preserved. I have preserves and trails in a database table dbo.reserveandtrail which is column for ID, trailname and reservename.

The issue I'm having problems with is how to select a trail when choosing the trails is selected on the protected dropdown. Is it possible to complete it using just CF or should I look in JS / Ajax?

itemprop = "text">

Sincerely Works either (jQuery / Ajax or Coldfusion built in AJAX functions ). It depends on the project. If you are not currently relying heavily on jQuery within the application, then ColdFusion is probably the fastest to implement and there is no dependency / import

If CFC functions are created correctly They will work with either so they can be used for any method too.

Here's a quick Coldfusion display ... Hope it helps.

==== html

  & lt; Cfform name = "test" & gt; & Lt; Cfselect name = "option1" & gt; & Lt; Option value = "" & gt; - Please select - & lt; / Options & gt; & Lt; Option value = "1" & gt; Option 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; Option 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; Option 3 & lt; / Options & gt; & Lt; / Cfselect & gt; & Lt; Cfselect name = "OPTION2" display = "suboption_display" value = "suboption_value" bindOnLoad = "true" dam = "cFC: webroot.jquery.stackoverflow.cascadingselect.applogic.select_binding ({OPTION1})" & gt; & Lt; / Cfselect & gt; & Lt; / Cfform & gt;   

== CFC

  & lt; Cfcomponent & gt; & Lt; Cffunction name = "select_binding" access = "remote" returntype = "query" & gt; & Lt; Cfargument name = "selected_option" type = "string" required = "yes" & gt; & Lt; Cfset dataset = QueryNew ('suboption_display, suboption_value', 'CF_SQL_VARCHAR, CF_SQL_INTEGER') & gt; & Lt; Cfswitch expression = "# arguments. Selected _uppression #" & gt; & Lt; Cfcase value = "1" & gt; & Lt; Cfset r = queryaddrow (dataset, 3) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_desplay', 'black', 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 1, 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_display', 'white', 2) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 2, 2) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_desplay', 'gray', 3) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 3, 3) & gt; & Lt; / Cfcase & gt; & Lt; Cfce value = "2" & gt; & Lt; Cfset r = queryaddrow (dataset, 3) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_display', 'red', 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 1, 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_display', 'blue', 2) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 2, 2) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_desplay', 'green', 3) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 3, 3) & gt; & Lt; / Cfcase & gt; & Lt; Cfcase value = "3" & gt; & Lt; Cfset r = queryaddrow (dataset, 3) & gt; & Lt; Cfset temp = querysetcell (dataset, 'sub_press_play', 'yellow', 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 1, 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_display', 'orange', 2) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 2, 2) & gt; & Lt; Cfset temp = querysetcell (dataset, 'sub_press_play', 'purple', 3) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 3, 3) & gt; & Lt; / Cfcase & gt; & Lt; Cfdefaultcase & gt; & Lt; Cfset r = queryaddrow (dataset, 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_display', '- option select option -', 1) & gt; & Lt; Cfset temp = querysetcell (dataset, 'suboption_value', 0, 1) & gt; & Lt; / Cfdefaultcase & gt; & Lt; / Cfswitch & gt; & Lt; Cfreturn dataset & gt; & Lt; / Cffunction & gt; & Lt; / Cfcomponent & gt;    

No comments:

Post a Comment