By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,405 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,405 IT Pros & Developers. It's quick & easy.

write into drop down box- Possible ????

P: n/a
I was just wondering, is it possible to write into the drop down box in
order to jump to a specific item. The reason why I am asking is my drop down
box has many items and additionally to the scrolling down, it would be good
if the user can write into the box in order to get the specific entry the
list selected.
Is this possible ?
Thanks.
Jul 20 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hello,
Sure, you can add new items to the listbox:

<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>

<body>
<script>
function addEntry(frm)
{
frm.s.options[frm.s.options.length] = new Option(frm.t.value,
frm.t.value);
}
</script>
<form name='f'>
New entry:<input type='text' value='[value]' name='t'><input type='button'
onclick='addEntry(this.form);' value='add entry'>
<br>
Listbox:
<select name='s'>
<option value='line1'>Line1</option>
</select>
</form>
</body>
</html>

"Filiz Duman" <no**@aol.com> wrote in message
news:bu**********@visp.bt.co.uk...
I was just wondering, is it possible to write into the drop down box in
order to jump to a specific item. The reason why I am asking is my drop down box has many items and additionally to the scrolling down, it would be good if the user can write into the box in order to get the specific entry the
list selected.
Is this possible ?
Thanks.

Jul 20 '05 #2

P: n/a

"lallous" <la*****@lgwm.org> wrote in message
news:bu************@ID-161723.news.uni-berlin.de...
Hello,
Sure, you can add new items to the listbox:

<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>

<body>
<script>
function addEntry(frm)
{
frm.s.options[frm.s.options.length] = new Option(frm.t.value,
frm.t.value);
}
</script>
<form name='f'>
New entry:<input type='text' value='[value]' name='t'><input type='button'
onclick='addEntry(this.form);' value='add entry'>
<br>
Listbox:
<select name='s'>
<option value='line1'>Line1</option>
</select>
</form>
</body>
</html>

"Filiz Duman" <no**@aol.com> wrote in message
news:bu**********@visp.bt.co.uk...
I was just wondering, is it possible to write into the drop down box in
order to jump to a specific item. The reason why I am asking is my drop down
box has many items and additionally to the scrolling down, it would be

good
if the user can write into the box in order to get the specific entry the list selected.
Is this possible ?
Thanks.


Thanks, but I did not mean writing in the sence of entering a new item into
the drop down box. I meant writing in the sence of entering the first letter
and then the second etc. and with this I would jump to that specific item
directly rather then scrolling to it ! (Mainly needed because my list is
quite long, so the user should have the possiblity to jump to the item
rather then scrolling all items in the drop down list !)


Jul 20 '05 #3

P: n/a
"lallous" <la*****@lgwm.org> wrote in message
news:bu************@ID-161723.news.uni-berlin.de...
<snip>
frm.s.options[frm.s.options.length] = new Option(frm.t.value,

<snip>

Though there is at leas one current browser that lakes the Option
constructor so it would be a good idea to check it exists prior to using
it (and consider the consequences of a design that requires it).

Richard.
Jul 20 '05 #4

P: n/a
On Wed, 21 Jan 2004 10:31:20 +0000 (UTC), Filiz Duman <no**@aol.com> wrote:
I was just wondering, is it possible to write into the drop down box in
order to jump to a specific item. The reason why I am asking is my drop
down box has many items and additionally to the scrolling down, it
would be good if the user can write into the box in order to get the
specific entry the list selected.


A SELECT element is a drop-down menu, or list box, only. You can only type
in INPUT and TEXTAREA boxes. In general, pressing a key in a drop-down
menu will take you to the first option that begins with that character[1].

The best you do, reliably, is make access easier for your users through
organisation. A couple of ideas...

- If possible, group items into catagories, and order them alphabetically,
numerically, or by some other logical order.
- If there are distinct groups, use two menus. The first should hold the
catagories. The second is then populated when a catagory is selected. This
can be done with JavaScript, but a non-JavaScript alternative (usually
implemented server-side) must be provided whenever possible[2].

Mike

[1] That isn't guaranteed behaviour.
[2] In fact, implementing this style *properly* could be quite involving.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #5

P: n/a
I have read the following message from "Filiz Duman" <no**@aol.com>
and have decided to lend my vast knowledge.

<snip>

Thanks, but I did not mean writing in the sence of entering a new item into
the drop down box. I meant writing in the sence of entering the first letter
and then the second etc. and with this I would jump to that specific item
directly rather then scrolling to it ! (Mainly needed because my list is
quite long, so the user should have the possiblity to jump to the item
rather then scrolling all items in the drop down list !)


and my reply is:
If you change your drop down box to a scrolling list (make lines
greater than 1) it will automatically scroll when you type a single
letter. At least it does on my browser. You first select the first item
in the list and then type a letter.

The only problem is when you select the first item an onchange event
takes place. You may need a separate button to activate the selection.

See my Amtrak page at my web site http://www.dcs-chico.com/~denmarks/

There is a list of hundreds of stations and it will scroll with no
special coding after selecting the first item.

--
Dennis M. Marks
http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #6

P: n/a
Yes, I would think you can just add an input text box to go along with
your drop-down box, and then everytime a key is pressed in the text box, use
a javascript loop to look thru the drop-down box's options[i].text for a
match with what is currently contained in your text box. If it finds a
match, then set that matching option[i].selected to "true" and it will
automatically scroll to the newly selected option[i].

Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.