Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Type in drop down menu in for Coldfusion

Posted on 2007-11-21
4
Medium Priority
?
711 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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…
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

927 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