473,508 Members | 2,357 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

making multiple elements visible

hi!

i have written a function to make visible elements with a certain id.
however i intended it to be used to make visible multiple elements but
it only appears to switch on the first element it comes to with that
id. after that it appears to stop. i was wondering how i can adapt this
function to make visible multiple elements, will i need a different way
of referencing or can it be done through id?

your thoughts are greatly appreciated on this...
function toggleLayer( layerID ) {

var style2 = document.getElementById( layerID );
if (style2.style.display == "block") {
style2.style.display = "none";
}
else {
style2.style.display = "block";
}

}
kind regards

marc

Jul 27 '06 #1
2 1769
libsfan01 said the following on 7/27/2006 5:02 PM:
hi!

i have written a function to make visible elements with a certain id.
however i intended it to be used to make visible multiple elements but
it only appears to switch on the first element it comes to with that
id.
Since ID attributes have to be unique in a document then the behavior
you describe is what it should do.
after that it appears to stop. i was wondering how i can adapt this
function to make visible multiple elements, will i need a different way
of referencing or can it be done through id?
Give your elements a class name and then change the CSS of that class.
Or, change the className of any divs that you want changed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 27 '06 #2
Thanks Randy.

Can anyone tell me the best way to get elements by classname?
Kind regards

Marc

Randy Webb wrote:
libsfan01 said the following on 7/27/2006 5:02 PM:
hi!

i have written a function to make visible elements with a certain id.
however i intended it to be used to make visible multiple elements but
it only appears to switch on the first element it comes to with that
id.

Since ID attributes have to be unique in a document then the behavior
you describe is what it should do.
after that it appears to stop. i was wondering how i can adapt this
function to make visible multiple elements, will i need a different way
of referencing or can it be done through id?

Give your elements a class name and then change the CSS of that class.
Or, change the className of any divs that you want changed.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7875
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option...
8
1783
by: Hansen | last post by:
Hi I have a form with multiple labels and textboxes and listboxes that need to be made visible and not visible when buttons are clicked. Is there anyway of grouping them together so that I have...
5
3297
by: Neil | last post by:
"lyle" <lyle.fairfield@gmail.comwrote in message news:48c3dde7-07bd-48b8-91c3-e157b703f92b@f3g2000hsg.googlegroups.com... Question for you. I'm doing something similar, only, instead of opening...
4
4479
by: vershner | last post by:
HI there, is it possible to make an element hidden, then make it visible again in the same function? I have a number of elements, only one of which should be visible at any time. The users can...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7494
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1553
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.