Jump to content

[SOLVED] make a Div Appear by a PHP Function and Disaper on click?


ThunderAI

Recommended Posts

you can do it with php if you must... but it'll involve either: AJAX or a page refresh..

 

You see, php is a Server-Side language.  This means that it once the page loads is not able to communicate to the browser... You need Client-Side code for this, such as javascript (like in the above example) or AJAX(still javascript, but in a more round about method.)

Here is what I did:

 

The javascript:

	<script>
		function closenotice() {
			document.getElementById("myDiv").style.display = "none";
			}
		</script>

 

The Div:

<div id="myDiv" style="display:none; position:absolute; z-index:9; left:300; top:300; width:400;">
<input type="submit" value="Close this Window" name="submit" class="button" onclick="javascript:closenotice();">
</div>

 

The PHP/More javascript:

<?php
					if ($tmp_number > 0) {
							?>
							<script>
								document.getElementById("myDiv").style.display = "block";
								//alert('You have unread messages \n Please check them by clicking the Notice Button');
								</script>

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.