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.)

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.