Popup Window Problem
Moderator: General Moderators
Popup Window Problem
I am trying to build a user error notification via. a popup window. I know that javascript can be used to create new windows, however most examples I've reviewed use some sort of "click" triggered mechanism to post the window. I'd like to popup a window with an error message to the user when the error occurs. For example, if the user does a file upload and inputs an invalid file type. In php code, when I determine the file type is invalid, I'd like to then popup a window with a corresponding error message.
thanx
crandym
thanx
crandym
on your jscript the link should be something like this:
<a href="javascripts:(void)" onclick="something()>click</a>
Something like that
What this is doing is onclick do something(then possibly a url here)
when php echos the <head> etc... make your body tag say <body onload="something()">
That should work
<a href="javascripts:(void)" onclick="something()>click</a>
Something like that
What this is doing is onclick do something(then possibly a url here)
when php echos the <head> etc... make your body tag say <body onload="something()">
That should work
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
he doesn't want it on a click, i think he laready knows how to do that... He is asking how to when theres an error...
The way i would do it would be the same way as an onClickevent for a link... except you could have the window open to a php page, and pass the error message through and have it display....
I'm pretty sure that'll work... may need a little tweaking but thats the basic idea
The way i would do it would be the same way as an onClickevent for a link... except you could have the window open to a php page, and pass the error message through and have it display....
Code: Select all
<script>
function PopUpError(error) {
javascript:window.open('popup.php?error=error', 'Error', 'width=300,height=200,menubar=0,toolbar=no,scrollbars=no')
}Code: Select all
//On Error:
?>PopUp($error);
<?php
//continue with code-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
oh, and on error.php just something like:
Code: Select all
<?php
$error = $_GET['error'];
echo $error;
?>Based on the little snippet of javascript posted above it should probably be:
Code: Select all
<?php
if($error) //blah blah, do whatever you want to check for an error
{
?>
PopUpError($error);
<?php
}
else
{
//other code...
}
?>heres wut u do
you need to use php to echo (""); the following on an error
<html><head><title>Untitled Document</title><script>function PopUpError(error) {
javascript:window.open('popup.php?error=error', 'Error', 'width=300,height=200,menubar=0,toolbar=no,scrollbars=no')
}
</head>
<body onload="popuperror($error)>
</body>
</html>
then if (error) {
echo all the above
}
//otherwise it keeps going
so on an error your php returns the html code for a page witha popup
is this waht your trying to do?
<html><head><title>Untitled Document</title><script>function PopUpError(error) {
javascript:window.open('popup.php?error=error', 'Error', 'width=300,height=200,menubar=0,toolbar=no,scrollbars=no')
}
</head>
<body onload="popuperror($error)>
</body>
</html>
then if (error) {
echo all the above
}
//otherwise it keeps going
so on an error your php returns the html code for a page witha popup
is this waht your trying to do?