[WEB4LIB] hiding and displaying an option element using JavaScript

Nick Dobbing ndobbing at uoguelph.ca
Fri Apr 15 13:41:49 EDT 2005


John, this might be a somewhat oblique response, but there are free scripts 
out there that do this kind of thing... have you considered using one? Here, 
for example:

http://www.dynamicdrive.com/dynamicindex16/chainedselects/index.htm

Regards,

Nick Dobbing
University of Guelph


----- Original Message ----- 
From: "John Fitzgibbon" <jfitzgibbon at Galwaylibrary.ie>
To: "Multiple recipients of list" <web4lib at webjunction.org>
Sent: Friday, April 15, 2005 1:21 PM
Subject: [WEB4LIB] hiding and displaying an option element using JavaScript


> 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