I need to build a dynamic dropdown list based on the selection of a other dropdown. Also I don't want to submit
the form since I have other data entry field on my form and don't want to lose the user entered data.
What is the best way to achive it using CF and/or Java Script. An example would really help to save the time since it is kind of urgent.
My first query is : select state from mydatabse.states
My second query is : select counties from mydatabase.counties where state = #state#
Thanks for the quick reply and example srikanthmadishetti:
Right now I am not using or don't want to use the CFC. So, can I just use the fuction in that example and build my second drop down in the same page? with regular HTML instead of CFSELCT etc.?
@Tpaul
>>>Right now I am not using or don't want to use the CFC. So, can I just use the fuction in that example and build my second drop down in the same page? with regular HTML instead of CFSELCT etc.?
Is there any specific reason for not using the cfselect or cfc
First it will be just few lines of code and second cfc will help you to reuse this code any where .
You can use it any form which has the state and country drop downs .
Sorry about the delay and Thanks for all your inputs.
I was able to created a custom tag successfully with the exaple provided by gdemaria. THANKS.
now the problem is , if I go bak and edit my order, I should be able to pre-select the options which I have selected originally like following.
<option value="#myvalue#" <cfif #ListFind(preselectedValue,query2.value1)#> #SELECTED</cfif>>#myvalue#</option>
I am going to try it by adding another parameters to my customtag and use the similar condition like above. But if you have a better solution, please update me.
Thanks
gdemaria
the custom tag has two parameters selected1 and selected2 representing the current values of the two select tags
Tpaul_10
ASKER
THANKS gdemaria.
Based on my requirements, your answer gave me the complete solution eventhough others have provided with different soluctions
https://www.experts-exchange.com/questions/24560682/ColdFusion-Ajax-Related-Selects.html