Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: Predictive text - drop-down(select) lists


Message #1 by "Jennifer O'Leary (WS2)" <JenniferO@W...> on Tue, 25 Jun 2002 09:54:04 +0100
Hi Jennifer

Populate the below Javascript with your ASP values:

<SCRIPT>
ar = new Array("asp values abc","def","ghi","jkl","mno","pqr")

function matchFieldSelect (field, select, value) {
  var property = value ? 'value' : 'text';
  var found = false;
  for (var i = 0; i < 46; i++)
    if ((found = select[i].indexOf(field.value) == 0))
    {
      break;
    }
  if (field.createTextRange) {
    var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;"
    if (cursorKeys.indexOf(event.keyCode+";") == -1) {
      var r1 = field.createTextRange()
      var oldValue = r1.text;
      var newValue = found ? select[i] : oldValue;
      if (newValue != field.value) {
        field.value = newValue
        var rNew = field.createTextRange()
        rNew.moveStart('character', oldValue.length)
        rNew.select()
      }
    }
  }
}
</SCRIPT>

Put relevant onKeyPress="matchFieldSelect (field, select, value)" in your
INPUT tag.

Rgds


Laphan


----- Original Message -----
From: Jennifer O'Leary (WS2) <JenniferO@W...>
To: HTML Code Clinic <html_code_clinic@p...>
Sent: Tuesday, June 25, 2002 9:54 AM
Subject: [html_code_clinic] Predictive text - drop-down(select) lists


Hello,

I have created a database-driven drop-down list using ASP. I would like this
drop-down list to respond using predictive text (like in VB) - that is, I
would like the drop-down to filter the list and highlight the first entry
corresponding to the letter(s) entered by the user. Does  anyone know an
easy way to do this?



Thanks,

Jen.




---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20






  Return to Index