Monday 26 August 2013

JAVASCRIPT: OK button proceed to another .php form

JAVASCRIPT: OK button proceed to another .php form

I have a basic javascript code for my saving entry.
Scenario:
I have two forms, the first form,[view_netbldg.php], is for my data entry
then when the user click the "ADD" button it will proceed to the next form
[save_netbldg.php]. So in my save_netbldg.php form there is a if else
condition where the code will know first if the variable of $bldgName or
$netName are empty. Everything is okay, but my concern is this when the
code detect either of the two variables are empty the code below I'm using
will be executed.
Here's my code:
if($bldgName == "" || $netName == "")
{
echo "<script type='text/javascript'>\n";
echo "alert('Please complete the fields for Building Name or Network
Name');\n";
echo "</script>";
header("location:view_netbdlg.php");
}
*The result of the program is, its not displaying the alert instead it
will jump to the header
The correct way is, if the $bldgName == "" || $netName == "" == true** an
alert will display and when the user click the ok button it will proceed
to the next form which is "view_netbdlg.php". I don't need a confirmation
message here because its only an error message something like that.
Advance thank you.

No comments:

Post a Comment