Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Brooklyn, NY
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question on passing a string to a function? Show/hide kind of thing

    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.

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Quick idea:

    function ChangeIt(X){

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

    }



    example to call it

    onclick="ChangeIt('TheElementId')"

  • #3
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Brooklyn, NY
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That seems to do the trick, thanks very much!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •