SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop Down / Not Listed = Enter Manual

    Hello there,

    I have a drop down list, which holds a massive list of places. If the user can not find their required place, they need to enter it manually. Could anyone suggest a solution to this problem.

    Do I create a field 'Not Listed' within the drop down and when that is selected a new box appears and they enter it there? I'm guessing php & java for that.

    Any suggestions would be great!

    Thanks

    Dave

  2. #2
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You could have a field labeled other that people can enter.
    To make this a little fancier, the other field could appear only if a "not listed" value is selcted in the drop down. That would be done with Javascript.

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Let them start typing, then use Ajax to suggest a match.

    If there is no match then they carry on typing.

    Look for "autocomplete ajax php"

  4. #4
    SitePoint Guru
    Join Date
    Jan 2007
    Posts
    971
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    Let them start typing, then use Ajax to suggest a match.

    If there is no match then they carry on typing.

    Look for "autocomplete ajax php"
    Very nice! I'm going to remember that.

  5. #5
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,862
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    HTML 5 is finally adding the combo box which is what you need to achieve that (a combination of input field and select list).

    The closest you can get for browsers that don't support that HTML 5 construct is to build it using an input field and a list with JavaScript to control the display of the list and to copy the selected list entry into the input field. See http://javascript.about.com/library/blcombo.htm for a JavaScript version that does it this way.

    The HTML 5 equivalent of the example on that page would be coded as:

    Code:
    <input type="text" list="state">
    <datalist id="state">
    <option value="act">
    <option value="nsw">
    <option value="nt">
    <option value="qld">
    <option value="sa">
    <option value="tas">
    <option value="vic">
    <option value="wa">
    </datalist>
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  6. #6
    SitePoint Member
    Join Date
    Mar 2010
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    Let them start typing, then use Ajax to suggest a match.

    If there is no match then they carry on typing.

    Look for "autocomplete ajax php"
    Thanks eruna!

    Top Google search worked perfectly!

    Thank you for all the suggestions!



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •