How to display an alert error message in php?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aditi_19
Forum Newbie
Posts: 23
Joined: Sun Jun 21, 2009 3:09 pm

How to display an alert error message in php?

Post by aditi_19 »

I have a php file which displays the list of all the client/vendor. There are options to add, update or delete any client/vendor. In order to select a client/vendor for updation or deletion, a radio button is provided with each of them.

Before redirecting the current page to update or delete page,I have a javascript code to check if any radio button is set or not. If it is, the page is redirected. Otherwise an error message is displayed. But this error message does not work fine all the time Is there any way to display error message dialogue box in php without use of Javascript? Or else what could be corrected in my code below to work fine?

Code: Select all

<?php
                session_start();
?>
 
<html>
<head>
         <script type="text/javascript">
 
            function submitAddPage(buttonName, nextPage)
            {
            var page = nextPage;
            var button = buttonName;
            if (button == "Add New")
            {
                document.userform.action = page;
                document.userform.submit();
            }
            }
 
            function submitPage(buttonName, nextPage,countno)
            {
            var page = nextPage;
            var button = buttonName;
            var count = countno;
            var c=0;
            var i=0;
 
            for(i=0;i<count;i++)
            {
                    if (document.userform.id[i].checked)
                    {
                    c=1;
                    break;
                    }
            }
 
            if (c == 1)
            {
                if (button == "Update")
                {       
                document.userform.action = page;
                document.userform.submit();
                }
 
                else if (button == "Delete")
                {
                document.userform.action = page;
                document.userform.submit();
                }
            }
 
            else if (c == 0)
            {
            alert('Select a user to Update/Delete...Use filter to perform a new search !');
            }
            }
        </script>   
 
</head>
<body>
[b]Php code and form elements[/b]
               
</body>
</html>
 
Post Reply