Solved

Type in drop down menu in for Coldfusion

Posted on 2007-11-21
4
693 Views
Last Modified: 2008-02-01
How can I create a typable dropdown menu in coldfusion.

I want to have the dropdown menu pull data from a query but also have the abliltiy to free type in something new.

How can I do this?

Thanks,
0
Comment
Question by:dunersbsquad
  • 2
4 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 20331945
Afaik its not possible with plain CF.  One option is to simulate it with javascript.  You could provide a text box and a button. When the button is clicked it adds the text to the select list.  

I've never used them, but if you look around there are some interesting scripts for "editable" select lists out there.

http://www.javascriptkit.com/script/script2/editableselect.shtml
http://www.dhtmlgoodies.com/index.html?whichScript=form_widget_editable_select
<script>

   function addOption() {

      var theList = document.getElementById('yourList');

      var newEntry = document.getElementById('newText').value;

      // may also want to look for duplicates and trim values

      if (newEntry.length > 0) {

	     // new Option( theListText, theListValue);

         theList.options[theList.options.length] = new Option(newEntry, newEntry);

         //auto-select new option

         theList.options[theList.options.length-1].selected = true;

      }

   }

</script>

<form>

   <select id="yourList" name="yourList">

      <option value="option 1">option 1</option>

      <option value="option 2">option 2</option>

      <option value="option 3">option 3</option>

   </select>

   <input type="text" id="newText" name="newText" size="10">

   <input type="button" value="Add" onClick="addOption();">

</form>

Open in new window

0
 
LVL 52

Expert Comment

by:_agx_
ID: 20331963
You might also try the suggestion here.   Seems to work with Firefox/Opera/IE6. Visually it looks almost like an editable control.

http://www.faqts.com/knowledge_base/view.phtml/aid/8220
Starting with "A simpler alternative goes like this: ..."
0
 
LVL 5

Accepted Solution

by:
mrigsby earned 500 total points
ID: 20332140
You could also use Ajax. The easiest way would by utilizing MXAjax. You can find it and documentation here... http://www.mxajax.com. Here is an example of the Auto Complete... http://www.indiankey.com/mxajax/examples/mxAutocomplete1.cfm
0
 
LVL 14

Expert Comment

by:Scott Bennett
ID: 20340696
If you have ColdFusion 8 you can use the autosuggest feature of the cfinput tag, it is not a drop down, of course that doesn't have the drop down feature so that may not be what you want:

<cfform>
Fruit: <cfinput type="text" name="fruit" autosuggest="apple,banana,orange,pear">
</cfform>

You can see a sample of what that would look like here:

http://www.coldfusionguy.com/ColdFusion/Samples/autosuggest.cfm

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now