Welcome Guest, Not a member yet? Register   Sign In
Combining jQuery and PHP for a simple alert Box?
#1

[eluser]Nummero2[/eluser]
Hi,

I want to show an simple jquery alert box within a simple if statement in php:

Code:
if($result == 0)
            {
            #-- ----------------------------------------------------------------------------
            #   Kein zugehöriges Protokoll vorhanden
            #-- ----------------------------------------------------------------------------

            ?>
            [removed]
            $(document).ready(function()
            {
                $("a").click(function() {
                alert("Hello world!");
                });

            });
            [removed]



            <?php
            

            }else
            {
            some other code

what I want. As the user you click on a href which leads to this view above. Now if there is nothing to show I want to display a popup alert window to notify the user that there is no entry at the moment present.

Am I on the right path?

Greetings Sebastian
#2

[eluser]Nummero2[/eluser]
Ok figured it out. I now got my alert by simply removing the click function handler.

Buuuuuuuuuuuuut

It would be great if the user clicks ok in the alert box that he is automatically redirected to another page. Is that possible?
#3

[eluser]Pascal Kriete[/eluser]
An alert blocks script execution, so right after the alert, add:
Code:
window . location = "http://www.gohere.com"; // remove the spaces

I will say though, that I despise random javascript alerts like this. So from a usability point of view, I would go a different route.
#4

[eluser]Nummero2[/eluser]
Thanks. Is it possible that the user is redirected to the previous page automatically?

The problem is that I "call" to this function from different locations in our app.

Can´t find anything.:-(
#5

[eluser]Nummero2[/eluser]
Got it, sorry.

"history.back();"




Theme © iAndrew 2016 - Forum software by © MyBB