Hi,
The following should be all you need to handle select boxes.
(I used main as form name and myitemlist as select box name.)
Rythmist
1. Determine the text or value of selected item
var Item = document.main.myitemlist.selectedIndex;
var Result = document.main.myitemlist.options[Item].value;
or
var Result = document.main.myitemlist.options[Item].text;
2. Set the selected option (index = 0 to number of items in list)
document.main.myitemlist.selectedIndex = [index];
3. Determine how many items in list
var Result = document.main.myitemlist.length;
4. Set the text of a select option. (Remember to reload page)
document.main.myitemlist.options[index].text = "Text";
history.go(0);
5. Test for multiple Items selected in list
for (Count = 0; Count < document.main.myitemlist.length; Count++){
if (document.main.myitemlist.[Count].selected){
Temp += "Option " + document.main.myitemlist.options[Count].text +
" is selected\n";
}
}
alert(Temp);
-----Original Message-----
From: Jack Killpatrick <[EMAIL PROTECTED]>
To: Web Consultants List <[EMAIL PROTECTED]>
Date: Wednesday, December 30, 1998 2:46 PM
Subject: WC:>: Cross-browser javascript Q
>Hi javascript support team ;-)
>
>Got a cross-browser problem this time. I have the following working in IE:
>
> function set_list(id_number){
> document.main.myitemlist.value=id_number;
> }
>
>myitemlist refers to <select name="myitemlist"> in the form "main", which
is
>loaded with options like this:
>
><option value="454545">This track
><option value="454546">That track
><option value="454547">Another track
>
>I use this code to fire the function:
>
> <a href="454545.ram" onclick="set_list('454545')">
> <a href="454546.ram" onclick="set_list('454546')">
> <a href="454547.ram" onclick="set_list('454547')">
> etc...
>
>The code works fine in IE4 (PC) : when the user clicks the audio track link
>the corresponding item becomes selected in the "myitemlist" select box, but
>in NS4.5 (PC) nothing happens, not even a javascript error.
>
>Wish I could show you this code, but it's on an intranet. :-(
>
>As always, any help is appreciated. None of my javascript books are giving
>me any clues.
>
>Thanks,
>Jack
____________________________________________________________________
--------------------------------------------------------------------
Join The NEW Web Consultants Association FORUMS and CHAT:
Register Today at: http://just4u.com/forums/
Web Consultants Web Site : http://just4u.com/webconsultants
Give the Gift of Life This Year...
Just4U Stop Smoking Support forum - helping smokers for
over three years-tell a friend: http://just4u.com/forums/
To get 500 Banner Ads for FREE
go to http://www.linkbuddies.com/start.go?id=111261
---------------------------------------------------------------------