[WEB4LIB] hiding and displaying an option element using JavaScript
Chris Gray
cpgray at library.uwaterloo.ca
Fri Apr 15 15:55:02 EDT 2005
I have a very simple example up at
<http://www.lib.uwaterloo.ca/~cpgray/js/hide.html>.
If you look at the source code you'll see that it is not done by hiding
elements, but by manipulating the Select object in the DOM.
Chris
"The brain is a wonderful organ. It starts working the moment you get up
in the morning and does not stop until you get into the office." -Robert
Frost
On Fri, 15 Apr 2005, John Fitzgibbon wrote:
> Hi,
>
> Hi,
>
> I need to hide a number of option elements in one drop down list based
> on the user selecting an option in another drop down list.
>
> The Javascript code I'm using is
>
> document.getElementById('starts4').style.display='none';
>
> where 'starts4' is the id of the option element I'm trying to hide. I
> tried using a span element within the option element and giving it an id
> of 'starts4' but to no avail.
>
> If the element is not an option element, everything works fine. The
> element appears and reappears as required.
>
> Using
>
> document.frmNameSearch.elements[4].options[1]=null
>
> is too messy, in this case, because it changes the index numbers of the
> option elements within the options array. Several options have to vanish
> and reappear depending on what is clicked and the changing of the index
> numbers makes it difficult to keep track of everything.
>
> If the first approach could be made to work it would save a great deal
> of typing.
>
> Any ideas would be very welcome.
>
> John Fitzgibbon
>
> Galway Public Library
> Island House
> Cathedral Square
> Galway
> Ireland
>
> p: 00 353 91 562471
> f: 00 353 91 565039
> w: http://www.galwaylibrary.ie
>
> *******************************************************************
> Tá eolas atá príobháideach agus rúnda sa ríomhphost seo
> agus aon iatán a ghabhann leis agus is leis an duine/na daoine
> sin amháin a bhfuil siad seolta chucu a bhaineann siad.
> Mura seolaí thú, níl tú údaraithe an ríomhphost nó aon iatán
> a ghabhann leis a léamh, a chóipáil ná a úsáid.
> Má tá an ríomhphost seo faighte agat trí dhearmad,
> cuir an seoltóir ar an eolas thrí aischur ríomhphoist
> agus scrios ansin é le do thoil.
>
> This e-mail and any attachment contains information which is
> private and confidential and is intended for the addressee
> only. If you are not an addressee, you are not authorised
> to read, copy or use the e-mail or any attachment.
> If you have received this e-mail in error, please notify
> the sender by return e-mail and then destroy it.
> *********************************************************************
>
>
More information about the Web4lib
mailing list