Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2008
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select field allowing input!!!!

    Hi! I am wondering if this can be done!! Can you help me.I want user to input value in a select field and upon starting inputing the value the input value which user is entering should be compared with the options of the select field and the value which match is displayed for user to select it,I want to reduce scrolling because the select field has a lot of options,its more or less the same like in browsers at the url input field when you start entering the url there are options in a drop down list

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Like this?:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    <meta http-equiv="Content-Script-Type" content="text/javascript">
    <script type="text/javascript">
    function selectOption(inp){
    var r=new RegExp('^'+inp.value,'i');
    var opt=inp.form['sel'].options, i=0, o;
    while(o=opt[i++]){
    if(o.value.match(r)){o.selected=true;break}
    }
    }
    </script>
    </head>
    <body>
    <form>
    select the country or input the first letter(s)
    <input type="text" onkeyup="selectOption(this)">
    <select name="sel">
    <option value="Afghanistan">Afghanistan</option>
    <option value="Albania">Albania</option>
    <option value="Algeria">Algeria</option>
    <option value="Andorra">Andorra</option>
    <option value="Antigua and Barbuda">Antigua and Barbuda</option>
    <option value="Argentina">Argentina</option>
    <option value="Armenia">Armenia</option>
    </select>
    </form>
    </body>
    </html>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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