I have this code to showor hide a div when click on button.But... If you ckick button the div appear.. but when you click again the div doesnt dissapear:|
Code:

function infoshowhide(){

      if(document.getElementById('info11').style.display = 'none')
      {
        document.getElementById('info11').style.display = 'block';
      }
      else 
      {
        document.getElementById('info11').style.display = 'none';
      }

}

and i need something like this for final result :

function infoshowhide(){
     contentxinfo=document.getElementById('info') + 'x'; //x is a nr i wish to make an array... info1 ...or info2 .. info3...this thing

      if(document.getElementById(contentxinfo).style.display = 'none')
      {
        document.getElementById(contentxinfo).style.display = 'block';
      }
      else 
      {
        document.getElementById(contentxinfo).style.display = 'none';
      }
};

i wish to make an array... info1 ...or info2 .. info3...this thing
can you help me :D?

Try asking on a Javascript forum. This one is for Java.

This fourum is for java too :D :p
Look on top of the page...

Software Development > Java > Showhide item

Java is not the same as JavaScript. You have posted in the wrong forum.

Here is a simple example you can use and modify it to fit you needs.

<!DOCTYPE html>
<html>
<head runat="server">
    <title>My Page</title>
<script type="text/javascript">

    function infoshowhide(id) {
        var e = document.getElementById(id);
        if (e.style.display == 'block')
            e.style.display = 'none';
        else
            e.style.display = 'block';
    }

</script>
</head>
<body>
<button onclick="infoshowhide('info11')">Show/Hide</button>
<div id="info11">Hello World!</div>
</body>
</html>

Thanks a lot for all replys

# You realy helped :D #

But i have one more question :))

function infoshowhide(id) {
    var e = document.getElementById(id);
    if (e.style.display == 'block')
        e.style.display = 'none';
    else
        e.style.display = 'block';
}

i wish to make something like that:

 function infoshowhide(id) {
    var e = document.getElementById(id) + X; //x is not a var... just x... :D
    if (e.style.display == 'block')
        e.style.display = 'none';
    else
        e.style.display = 'block';
}

how is corecct code for an array.. unite e with x :

Example:

e = info11
I need to change style for element with id info11x so i just need to add x to may variable..
How can i do this :D?

hmm... so I may not be understanding you correctly, but you are asking that you just want to add the string value of "x" to the ID you are passing? Ok, if so, you have to do it before you assign the value of e. if you do this, then your element ID that you are targetting needs to be,in this case, "info11X" for this to still work.

function infoshowhide(id) {
    id = id + "X";
    var e = document.getElementById(id);
    if (e.style.display == 'block')
        e.style.display = 'none';
    else
        e.style.display = 'block';
}