Web Analytics Made Easy -
StatCounter Message Box using a php function - CodingForum


No announcement yet.

Message Box using a php function

  • Filter
  • Time
  • Show
Clear All
new posts

  • Message Box using a php function


    is there any php function to create a Message Box like the following javascript function does?

    if(confirm('Are you sure you want to delete tihs record?')) {
    else {
    Of course I want that the value of the click will be returned into a php $variable. Like the 'LogOut' menu in this Forum does.

    Thanks in advance.
    Last edited by nst; Jul 29, 2005, 05:34 AM.

  • #2
    I believe PHP cannot create a Message Box BUT PHP can be used to create JavaScript just as PHP can create HTML...


    • #3
      You'll have to use a form and then process it with php

      What would you like to show?
      CATdude about IE6: "All your box-model are belong to us"


      • #4
        You'd need it to refresh the page or redirect to another page via a form or something to be able to get what you want done


        • #5
          Thanks for replying.

          What I want to achieve is very common and probably very easy too. For instance, when I click 'Log Out' on the upper right corner of this page a MessageBox comes up asking me if I am positive about my intention.

          I checked the source and I found the following:

          <a href="login.php?do=logout" onclick="return log_out()">
          Log Out
          Therefore, I assume there may be a function which interprets the click (Yes|No) in the appropriate manner.

          Now that I am rethinking of it, is it maybe a pure javascript thing? But, why then "login.php?do=logout"?


          • #6
            function log_out()
            	return confirm('Are you sure you want to log out?');
            <a href="login.php?do=logout" onclick="return log_out()">Log Out</a>
            i've removed everything that doesn't matter. confirm() is a javascript method that pops up and returns true if the user clicks OK and false if the user clicks Cancel. in an <a>, if onclick returns false, the action ends and the link is not followed. i hope this is a good explanation.


            • #7

              It took me some time to realize (being anxious for applying it I did not read you message carefully) that function log_out() was NOT a php function but ... of course a javascript function!

              The rest is clear and simple. I tried it succesfully. Thanks to everyone for the help.