[Javascript] Re: ComboBox

David Lovering dlovering at gazos.com
Fri Mar 21 14:03:04 CST 2003


Indeed, that will work, but the penalty is that every keystroke event will
poke the searchSelect routine.  I usually rig it so that a CR, tab, or a
blur event triggers the parsing, just to keep the overhead down.  However,
keystrokes are usually pretty minimal in the interrupt department, so I
don't imagine it would hurt anything to do it your way.  [Plus you can
correct them at the moment the syntax starts to go south, rather than making
them retype part of their entry].

-- Dave Lovering


----- Original Message -----
From: "Chris Tifer" <christ at saeweb.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Friday, March 21, 2003 6:58 AM
Subject: Re: [Javascript] Re: ComboBox


> Do as I suggested then where on the onKeyUp event of the <INPUT> element
> you take the string and loop through the elements in your <SELECT> looking
> for that value.
>
> Here's a simple example you can look at to see what I'm talking about:
>
>
> <HTML>
>
> <head>
> </head>
>
> <form name="Test1">
>
> <input type="text" name="myText" onKeyUp="searchSelect('Test1',
'mySelect',
> this.value)">
>
> <br />
>
> <SELECT name="mySelect">
>  <OPTION VALUE="PostOffice">PostOffice
>  <OPTION VALUE="GoPostal">GoPostal
>  <OPTION VALUE="Postman">Postman
> </SELECT>
> </form>
>
>
> <script language="Javascript">
>
>
> function searchSelect(strMyForm, strMyEl, strText){
>  var objForm = document.forms[strMyForm]
>  var objEl = objForm.elements[strMyEl]
>  if(strText.length > 0){
>   for(var x = 0; x < objEl.options.length; x++){
>    if(objEl.options[x].value.toLowerCase().indexOf(strText.toLowerCase())
>=
> 0){
>     //alert(objEl.options[x].value.indexOf(strText))
>     objEl.options[x].selected = true
>     return
>    }
>   }
>  }
> }
> </script>
>
> </HTML>
>
>
>
>
> ----- Original Message -----
> From: "andy susanto" <andy78 at centrin.net.id>
> To: <javascript at LaTech.edu>
> Sent: Friday, March 21, 2003 3:11 AM
> Subject: [Javascript] Re: ComboBox
>
>
> > Hai,
> >
> > sorry for my question. Because i do not know in javascript name object
> > <Select>, so i call that a combobox( because my background is Delphi).
> What
> > i want is when i type a char i can see that char like <input> and i can
> > insert not just a char but i can insert two and more char. example:
> >
> > <Option>PostOffice</Option>
> > <Option>Postman</Option>
> >
> > when i type "Post" maybe that<select> will focus on PostOffice, when i
> type
> > a char again "m" <select> will focus on Postman
> >
> > TIA,
> >
> > andy
> >
> >
> > > There are no comboboxes in HTML actually unless you want to do
> > > some fancy programming or use an Active X component of some
> > > sort.
> > >
> > > But on a SELECT list, if you press a key and that is the first
character
> > for
> > > any of the OPTIONS, it will cycle through those that match.
> > >
> >
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list