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

Announcement

Collapse
No announcement yet.

Message Box using a php function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Message Box using a php function

    Hello,

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

    Code:
    if(confirm('Are you sure you want to delete tihs record?')) {
    document.write('OK');
    }
    else {
    document.write('NOOO!');
    }
    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...

    Comment


    • #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"

      Comment


      • #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

        Comment


        • #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:

          Code:
          <a href="login.php?do=logout" onclick="return log_out()">
          Log Out
          </a>
          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"?

          Comment


          • #6
            Code:
            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.

            Comment


            • #7
              Hi.

              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.

              Comment

              Working...
              X