Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2006

    Predictive Text Menu

    I'm working on something which will have a form containing a select menu with a lot of items (around 1000-2000, maybe more). I would like to have a text box next to the list with predictive text input, so when you start typing in a text box it will choose the first item in the list starting with what you've typed so far.

    For example, if this is the drop down list...:


    ... and you type "el" in the box, it will choose Elephant. Also, if you do decide to click in the list, it will put the item you choose into the text box.

    Even better would be if there's a way to make it in one thing (ie. you can type straight into the select menu) that would be good, but I wouldn't think that's possible...

    thank you in advance

  2. #2
    Join Date
    Oct 2006

  3. #3
    I guess, you need an advanced javascipt for this.

    Guess, the code is quite complex that nobody replied. You could perhaps go to elance and hire a programmer for this one.

    In Delphi (desktop based) this thing could be done in two or three line codes. Guess, it's a little bit complicated with web.

  4. #4
    Join Date
    Oct 2006
    I do not have enough resources at present point to pay one maybe anyone knows a place where there might be someone who knows answer??

  5. #5
    I'm willing to help, but I'm at the early stage of learning Javascript. It would take me some months to create the script

    How about you ask someone, and ask for service exchange. So, you get the script, then you "pay" by your service or some products in your possession.

    Everybody needs something in their life that they can't have.
    Affordable web hosting and also a reliable web hosting.
    24x7 support. Dedicated for your online business needs, with complete scripts (milist, blog, autoresponder, audio, video, etc) and monthly products with (Master) Resell Rights.

  6. #6
    Here's one way. Depending upon how many words in your predictive text list there are to check you may want to consider using Ajax to pass off the actual checking back to your server. It's pretty simply, loads of Ajax examples on the web.
    <script language='javascript'>
    // short list of predictive words, add as many as you like
    // deliberately selected some that share first few chars
    var preWords=new Array('hello','help','goodbye','google','watch-ya','watch');
    // declare shorthand function
    function gId(id) {
      return document.getElementById(id); 
    // param: inp - reference to INPUT
    function checkPredict(id) {  
      var result='';
      if (word.length==0) // comment out these 2 lines if you don't want all options
        return "";           // displayed when function is called and INPUT is empty
      for (var i=0;i<preWords.length;i++) { // loop through predict words
        if (preWords[i].substr(0,word.length)==word) // if our first few chars match
          result+=preWords[i]+"\r"; // store the matched word using \r as separator
      resultArr=result.split("\r"); // turn back into array [using separator saves 2nd index]
      for (var i=0;i<resultArr.length;i++) {
        fResult+="<a href='javascript:void(0)' onclick='gId(\""+id+"\").value=\""+resultArr[i]+"\"'>"+resultArr[i]+"</a>&nbsp;"
      return fResult;
     <!-- need a form as some browsers won't render INPUT without one -->
     <form name='ptxt' id='ptxt'>
       <input name='txtin' size=50 onkeyup='gId("ptxtlist").innerHTML=checkPredict("txtin")'><br/>
       <div id='ptxtlist'></div>
    If you PM me then I'll let you have the invoice, LOL

  7. #7
    Join Date
    Oct 2006
    thank you I will try this out

Posting Permissions

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