Link to home
Start Free TrialLog in
Avatar of Tpaul_10
Tpaul_10Flag for United States of America

asked on

Building or creating dynamic drop down

Experts,

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 in Advance
Avatar of SRIKANTH MADISHETTI
SRIKANTH MADISHETTI
Flag of India image

Avatar of Tpaul_10

ASKER

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.?
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@brijesh Good to see you in EE :)

@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 .

I have old cold fusion code and the site is going away soon. So, no CFCs and don't want to spend money for buying the code -:(

I may look in to writing a custom tag, but need to find out if the tables are related to have one query.
May be an example would be helpful.

I provided you with a custom tag:   cf_twoselectsrelated

 http://projects.nateweiss.com/nwdc/workcode.htm

> but need to find out if the tables are related to have one query

The would have to be related, wouldn't they?   Otherwise, you don't need two related select tags, you could just do two distinctly seperate tags, right?

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
the custom tag has two parameters selected1 and selected2 representing the current values of the two select tags
THANKS gdemaria.
Based on my requirements, your answer gave me the complete solution eventhough others have provided with different soluctions