Results 1 to 2 of 2

Thread: z-index

  1. #1
    Join Date
    May 2005
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default z-index

    i am using this code so that when i click on a dragable element, it comes to the top. how could i change it so that when i click on an object, a different object comes to the top. basicall i want to be able to hit a picture which will make a table appear.

    Code:
    <script language="Javascript">
    <!--
    last_z=""
    function which_z(n){
    document.getElementById(n).style.zIndex=6
    if(last_z==""){
    last_z=n
    }
    else{
    document.getElementById(last_z).style.zIndex=""
    }
    last_z=n
    }
    // -->
    </script>
    Code:
    onmouseup="which_z(this.id)"

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I'm going to assume that your code is working even though I think this last bit should be:

    Code:
    else{
    document.getElementById(last_z).style.zIndex=""
    last_z=""
    }
    }
    Can't be certain though. OK, if it works, you just need to pass the id of the table or whatever object as a literal string. Let's say the table has an id of 'tbl1':

    HTML Code:
    <table id="tbl1"><tr><td> . . .
    Your event would be:

    Code:
    onmouseup="which_z('tbl1')"
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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