...

View Full Version : Question on passing a string to a function? Show/hide kind of thing



cameronc
06-12-2003, 08:17 PM
I'm trying to make a little function that shows an image and description of something when its link is moused over. All the elements are set to style="display:none". I'm trying to pass the ids of the image and the description to the function. This is where I am now:

<script language="JavaScript">

function showsample(x,y) {
var a = new String(x);
var b = new String(y);

window.a.style.display = "block";
window.b.style.display = "block";

}
</script>

Is there any way to do something like this? I want a and b to be the ids. I'm passing them to the function from the mouse over event. I know that window.a.style etc. isn't working.

A1ien51
06-12-2003, 09:19 PM
Quick idea:

function ChangeIt(X){

document.getElementById(X).style.visibility="hidden"

}



example to call it

onclick="ChangeIt('TheElementId')"

cameronc
06-12-2003, 09:33 PM
That seems to do the trick, thanks very much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum