Jump to content

Show/Hide Div


Dysan

Recommended Posts

<html>
<head>
<title></title>
</head>

<body>
  <input type="button" name="Submit" value="Show" onclick="javascript:document.getElementById('thehidden1').style.display='block'; return true">
  <input type="button" name="Submit2" value="Hide" onclick="javascript:document.getElementById('thehidden1').style.display='none'; return true">
<div id="thehidden1" style="width:300px;height:225px;border:solid 1px black;display:none">

</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/83536-showhide-div/#findComment-425036
Share on other sites

<html>
<head>
<title></title>

<script language="javascript">
function showIt()
{
document.getElementById('thehidden1').style.display='block';
}
function hideIt()
{
document.getElementById('thehidden1').style.display='none';
}
</script>

</head>

<body>
  <input type="button" name="Submit" value="Show" onclick="showIt()">
  <input type="button" name="Submit2" value="Hide" onclick="hideIt()">
<div id="thehidden1" style="width:300px;height:225px;border:solid 1px black;display:none">

</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/83536-showhide-div/#findComment-425496
Share on other sites

  • 1 month later...

<html>
<head>
<title></title>
</head>

<body>
  <input type="button" name="Submit" value="Show" onclick="javascript:document.getElementById('thehidden1').style.display='block'; return true">
  <input type="button" name="Submit2" value="Hide" onclick="javascript:document.getElementById('thehidden1').style.display='none'; return true">
<div id="thehidden1" style="width:300px;height:225px;border:solid 1px black;display:none">

</div>
</body>
</html>

 

I changed this code to use <a href=""> tags:

 

<?php
<a href="" onclick="javascript:document.getElementById('thehidden1').style.display='block'; return true">show</a>
<a href="" onclick="javascript:document.getElementById('thehidden1').style.display='none'; return true">hide</a>
<div id="thehidden1" style="width:300px;height:225px;border:solid 1px black;display:none;">
<p>CAN WE SEE THE WIBBLES?</p>
</div>
?>

 

but the division only shows for a split second. Could you please advise what I need to change to make the display:block permenant until the "hide" link is clicked?

 

Many thanks as always,

 

James.

Link to comment
https://forums.phpfreaks.com/topic/83536-showhide-div/#findComment-461616
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.