Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

function to show and hide divs 2

Status
Not open for further replies.

leujel

Programmer
May 28, 2003
23
0
0
NL
I'm a nOOb to javascript. I'm just starting, and can't figure out why my script gives an error.

I've made a function that shows a div and hides a variable number of other divs.

This is the function:
Code:
function showdiv(show, hide) {
			// show div
			var obj= document.getElementById(show);
			obj.style.visibility = "visible";
			
			//hide div
			arr = hide.split(",");
			var aantal = arr.length;
			for(i = 0; i < aantal; i++)	{
				document.getElementById(arr[i]).style.visibility = "hidden";
			}
		}

I address the function at the following way:
Code:
<a href="javascript: void(0)" onClick="javascript: showdiv('divtoshow', 'divtohide1, divtohide2');">Link</a>

Bu this doesn't seem to work... Can anyone tell me why? I've searched several sites, tried several solutions, but none worked.

Thanks in advance

---------------

Visit Stray Cats Fan!! Go Cat!! Go!!
 
1) try removing the space after the comma.
2) try calling this in a different manner.

Code:
<a href="#" onclick="showdiv('divtoshow', 'divtohide1,divtohide2'); return false;">Link</a>



*cLFlaVA
----------------------------
[tt]( <P> <B>)[sup]13[/sup] * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top