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
Solved

Type in drop down menu in for Coldfusion

Posted on 2007-11-21
4
697 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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