ThunderAI Posted June 14, 2008 Share Posted June 14, 2008 I have function that counts the number of notices a user has and if it is over 0 i want either an alert or a custom div layer to apear. How can I set up the javascript to activate if the function passes a number over 0 to it? Quote Link to comment Share on other sites More sharing options...
kbh43dz_u Posted June 14, 2008 Share Posted June 14, 2008 <div id="myDiv" style="display:none"></div> and when you pass something bigger to your javascript function it could do this to make it appear: document.getElementById("myDiv").style.display = "block"; Quote Link to comment Share on other sites More sharing options...
schme16 Posted June 14, 2008 Share Posted June 14, 2008 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.) Quote Link to comment Share on other sites More sharing options...
ThunderAI Posted June 14, 2008 Author Share Posted June 14, 2008 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> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.