473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Beginners question...

Fix
Hi,

There probably is a very simple and basic solution for what i want, but i
just don't know how...

I have this script, which could be much shorter:

function hidediv(id) {
document.getElementById(id).style.display='none';
}

activated by:

<div onclick="hidediv('one');hidediv('two');hidediv('th ree')">click</div>

How can I adjust this script to activate it by:
<div onclick="hidediv('one','two','three')">click</div>

Thanks!
Jul 20 '05 #1
2 2603


Fix wrote:
Hi,

There probably is a very simple and basic solution for what i want, but i
just don't know how...

I have this script, which could be much shorter:

function hidediv(id) {
document.getElementById(id).style.display='none';
}

activated by:

<div onclick="hidediv('one');hidediv('two');hidediv('th ree')">click</div>

How can I adjust this script to activate it by:
<div onclick="hidediv('one','two','three')">click</div>


To have a function processing a variable number of arguments use the
arguments array:

function hideDivs () {
var el;
for (var i = 0; i < arguments.length; i++) {
if (document.all)
el = document.all[arguments[i]];
else if (document.getElementById)
el = document.getElementById(arguments[i]);
if (el && el.style)
el.style.display = 'none';
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Fix

Great! Thanks!!


Fix wrote:
Hi,

There probably is a very simple and basic solution for what i want, but i just don't know how...

I have this script, which could be much shorter:

function hidediv(id) {
document.getElementById(id).style.display='none';
}

activated by:

<div onclick="hidediv('one');hidediv('two');hidediv('th ree')">click</div>
How can I adjust this script to activate it by:
<div onclick="hidediv('one','two','three')">click</div>


To have a function processing a variable number of arguments use the
arguments array:

function hideDivs () {
var el;
for (var i = 0; i < arguments.length; i++) {
if (document.all)
el = document.all[arguments[i]];
else if (document.getElementById)
el = document.getElementById(arguments[i]);
if (el && el.style)
el.style.display = 'none';
}
}

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

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

Similar topics

7
by: Will | last post by:
Pardon two post in a row to the newsgroup but I want to try and expedite this, if you guys don't mind helping out... I running Windows XP Pro and wanted to download Python and any additional...
4
by: blah | last post by:
I m actually a Novice in Python as well as Linux, When i look up things on the internet about Linux Flavours, They are written so complex that it is difficult for me to understand, i am asking if...
4
by: Eggnog | last post by:
Hi, Is there a newsgroups for beginners questions? Cheers, Nawg
6
by: William Foster | last post by:
Does anyone know of a good online tutorial for C# focused on beginners. I have been to many great sites like csharpfriends, csharp-corner etc looking for good tutorials and have had no luck. Any...
18
by: John Salerno | last post by:
Hi all. I was hoping some of you could recommend a book or two that would help me get started with the basics of C#. I have a slight knowledge of programming, but basically I want to start out like...
2
by: =?Utf-8?B?UmFrZXNo?= | last post by:
Hi, I have worked in Windows development for some time and want to learn ASP.Net - Web Application. Can some one redirect me to some site where I can find some good start up for beginners course...
4
by: aman firoz | last post by:
do you people got anything for c beginners..... help me out guys
0
by: Dual_b00t | last post by:
hi i created a site called PHP Together its for beginners also for gurus to help out the beginners if you are learning PHP and feel alone then drop by . ciao Mark
19
by: yltkhuu | last post by:
1. How does having a widely adopted C++ standard help game programmers? 2. What are the advantages ans disadvantages of employing the "using" directive? 3. Why might you define a new name for an...
6
by: Lars | last post by:
Hi all If this is the wrong list for beginners trouble I apologize. please refer to me the correct list in such case. I am trying to create a simple linked list but I keep getting segmentation...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.