[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to auto fill an option tag based on a previous selection

Posted on 2008-06-25
3
Medium Priority
?
218 Views
Last Modified: 2012-06-22
I am trying to setup a form as follows

User makes a selection from an option drop down that pulls the options from a database

I then want the next box to auto fill based on the selection from above

Both options are derived from a database

so as an example

User selects a state from a drop down
The next box has the State Abbreviation and I want that to be auto filled in based on the state name

How do I do this
0
Comment
Question by:ostashenp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 1000 total points
ID: 21867694
this shows you how it works

<cfoutput><cfset TempQry= querynew("")>
 
<cfset queryaddcolumn  (TempQry, "Col1", "CF_SQL_integer", ListToArray("1,2,3,4,5,6"))>
<cfset queryaddcolumn  (TempQry, "Col2", "cf_sql_varchar", ListToArray("here, there, everywhere, nowhere, anywhere,somewhere"))>
<select onChange="document.getElementById('stateName').value=this.value;">
<cfloop query="tempqry">
<option value="#tempqry.col1#">#tempqry.col2#</option>
</cfloop>
</select>

<select id="stateName">
<cfloop query="tempqry">
<option value="#tempqry.col1#">#tempqry.col2#</option>
</cfloop>
</select>

</cfoutput>


however do you really need to select a state and and fill another option with the abbreviation? unless there's a specific need why not just use the stateabbr as the option value and the statename as the option text

<option value="#tempqry.stateabbr#">#tempqry.statename#</option>





0
 
LVL 36

Expert Comment

by:SidFishes
ID: 21867704
btw..this bit

<cfset TempQry= querynew("")>
 
<cfset queryaddcolumn  (TempQry, "Col1", "CF_SQL_integer", ListToArray("1,2,3,4,5,6"))>
<cfset queryaddcolumn  (TempQry, "Col2", "cf_sql_varchar", ListToArray("here, there, everywhere, nowhere, anywhere,somewhere"))>

just creates a temp query for testing you'd replace that with your own query
0
 
LVL 39

Assisted Solution

by:gdemaria
gdemaria earned 1000 total points
ID: 21867946
You have two select tags, the second should populate based on the selection of the first; true?  

Here is a coldfusion custom tag that does that for you...

http://www.geocities.com/thanny/CF_TwoSelectsRelated.zip
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
While opting for any web-to-print solution, you need to discuss with your team and some of your end users and know their opinions about your decisions. In this article we list down some questions you need to ask yourself.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question