0

I need to output alert message if val = -1, but the problem is that this message appears at the bottom of the page and this does not depend on the value of val.

if ($val == -1) 
        echo '
        <script>
            $(function() {
                $( "#dialog:ui-dialog" ).dialog( "destroy" );
                $( "#dialog-message" ).dialog({
                    modal: true,
                    buttons: {
                        Ok: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            });
        </script>
        ';
    else { //...  }


<div id="dialog-message" title="Process failed.">
<p><span class="ui-icon ui-icon-circle-check"
    style="float: left; margin: 0 7px 50px 0;"></span> Error message.</p>
</div>
1
  • Your HTML is outside of your if statement, meaning that it will always display. You need to use css to hide it and what I would also do, is only add the HTML for the dialog when you need to show it, i.e. within the if statement. Commented May 24, 2012 at 13:18

3 Answers 3

1

To hide the div use css

#dialog-message{
 display:none;
}

For a better alert there is a nice plugin for Alert, Confirm & Prompt use that plugin

http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

It's download page is here

http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/

Sign up to request clarification or add additional context in comments.

Comments

1

You can use position function to position the dialog:

Link

Comments

0

What's wrong with the good old fashioned alert() javascript function? It should do the job just fine in this situation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.