Is there a way to get a javascript error to pop up when information returned from a data base querry is false?
I want to check a data base to see if the information matches, if not pop up an error message instead of an html page. I got the idea from a similar function in a script. All I have been able to find is mostly mouse or window events.
Javascript error message
Moderator: General Moderators
Not exactly. It's after I query. I want to compare values entered in a form to values in the data base.
Code: Select all
if ($est_option_id != $group_value_id) { I want an error here if they don't match.... }I'm trying to avoid popping up a different window. I like the error messages that you can use with javascript. They just pop up a warning, like this. I know how to get it to open a new window using php, if returned false. Is there a way to activate the javascript without and event from the client?
Code: Select all
<a href="#" onClick="javascript:alert('$la_no_del_sorry_val')"><font color="#990000">$la_inv_del</font></a>Ok, in that case just echo() the JavaScript to the page if the values don't match... but adding an error to the page as actual text (HTML) is a lot nicer and won't get on peoples nerves as much as an alert box would.
Code: Select all
<?php
// The values don't match so add some JS to the page
$errorText = "The values don't match!";
echo <<< END
<script type="text/javascript">
window.onload = function () { alert("{$errorText}"); }
</script>
END;
?>