2

I am trying to make a JavaScript visibility function where when I press the button of the image it appears. the image does not appear though. I have the images hidden as I only want them to show when the button is pressed. what can I do to fix this?

<html>
<head>
<style type="text/css">
#xbone {
    position:absolute;
    margin-left: auto;
    margin-right: auto;
    visibility: hidden;
}
#ps4 {
    position:absolute;
    margin-left: auto;
    margin-right: auto;
    visibility: hidden;
}
#wiiu {
    position:absolute;
    margin-left: auto;
    margin-right: auto;
    visibility: hidden;
}
</style>
<script type="text/javascript">
function xbox()
    {
        document.getElementById("xbone").style.visibility="visible";
    }
    funtion sony()
     {
        document.getElementById("xps4").style.visibility="visible";
    }
    funtion nintentdo()
     {
        ddocument.getElementById("wiiu").style.visibility="visible";
    }
</script>
<img id="xbone" src="http://assets1.ignimgs.com/vid/thumbnails/user/2013/06/19/XboxOne1.jpg" alt="Xbox One" width="800" height="600">
<img id="ps4" src="http://gamingbolt.com/wp-content/uploads/2013/06/ps4-hd-wallpapers.jpg" alt="Playstation 4" width="800" height="600">
<img id="wiiu" src="http://www.digitaltrends.com/wp-content/uploads/2012/09/Wii-U.jpg" alt="Wii U" width="800" height="600">
<input type="button" value="XBox One" onclick="xbox()">
    <input type="button" value="Playstation 4" onclick="sony()">
        <input type="button" value="WII U" onclick="nintendo()">
</head>
<body>

</body>
</html>
BenMorel
  • 34,448
  • 50
  • 182
  • 322
cpom1
  • 25
  • 1
  • 5

4 Answers4

2

The first real answer:

<div style = "visibility:hidden" id = "xbone"><img src = "xbone.jpg" /></div>
<button type = "button" 
onclick = "document.getElementById("xbone").style.visibility =
"visible"">Display XBONE</button>

But make sure and fix the grammar errors too.

Durnehviir
  • 56
  • 1
  • 8
0

just an idea, ... use steganography methods such as RGB (lsb) and hide a picture inside another picture. whenever press button, steganography reverse works and appears the hidden picture. i used stepic in python and worked fine.no idea bout java. sorry if its not helping, am still new :)

kali.python
  • 41
  • 1
  • 5
0

You have a lot of typos.

funtion nintentdo() should be function nintendo()

ddocument.getElementById("wiiu") should be document.getElementById("wiiu")

You should also take your imgs and inputs out of the <head> and put them in your <body>.

rla4
  • 1,228
  • 13
  • 25
0

Check this post - Show/hide image with JavaScript

Also your html structure is incorrect, it should be:

<html>
    <head>
        <style type="text/css">
        </style>
            <script type="text/javascript">
            </script>
    </head>
<body>

    <!-- all content goes here -->

</body>
</html>
Community
  • 1
  • 1
Geblord
  • 63
  • 4