By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

pop up messages in php

P: 65
Hi friends,
Can anyone tell me how can I create pop up messages in PHP...??
Is it possible in PHP?
Pop up messages in the sense, it should be triggered during the users entering their input in a form.
Plz.....Show me some sample codes........


Thanx n Regards
Yas
Feb 26 '08 #1
Share this Question
Share on Google+
6 Replies


P: 11
-yasmine
php is server-side scripting.. meaning that the code is processed by the server not by the client. You need to use client side code.
just use javascript.
like so:
Expand|Select|Wrap|Line Numbers
  1. <script type="javascript">
  2. function popUp
  3. (URL,Width,Height,Left,Top,Toolbar,Resizeable,ScrollBars,MenuBar,
  4. StatusBar,Resizeable) {
  5. Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
  6. Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
  7. ScrollBars = ScrollBars==null||ScrollBars==""?1:ScrollBars;
  8. MenuBar = MenuBar==null||MenuBar==""?1:MenuBar;
  9. StatusBar = StatusBar==null||StatusBar==""?1:StatusBar;
  10. Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
  11. day = new Date();
  12. id = day.getTime();
  13. eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar="+Toolbar+",scrollbars="+ScrollBars+",location=1,statusbar="+
  14. StatusBar+",menubar="+MenuBar+",resizable="+Resizeable+",width="+
  15. Width+",height="+Height+",left="+Left+",top="+Top+"');");
  16. }
  17. </script>
  18.  
  19. and call it like so on an onclick event on a input box or something:
  20.  
  21. <input id="Pod_ID" onclick="popUp("http://yourwebsite.com/",600,400,200,200,);" type="text" />
-odobo
Enclose your code within the appropriate code tags!! - moderator
Hi friends,
Can anyone tell me how can I create pop up messages in PHP...??
Is it possible in PHP?
Pop up messages in the sense, it should be triggered during the users entering their input in a form.
Plz.....Show me some sample codes........

Thanx n Regards
Yas
Feb 26 '08 #2

P: 65
-yasmine
php is server-side scripting.. meaning that the code is processed by the server not by the client. You need to use client side code.
just use javascript.
like so:
<script type="javascript">
function popUp(URL,Width,Height,Left,Top,Toolbar,Resizeable ,ScrollBars,MenuBar,
StatusBar,Resizeable) {
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
ScrollBars = ScrollBars==null||ScrollBars==""?1:ScrollBars;
MenuBar = MenuBar==null||MenuBar==""?1:MenuBar;
StatusBar = StatusBar==null||StatusBar==""?1:StatusBar;
Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar="+Toolbar+",scrollbars="+ScrollBars+",loc ation=1,
statusbar="+StatusBar+",menubar="+MenuBar+",resiza ble="+Resizeable+
",width="+Width+",height="+Height+",left="+Left+", top="+Top+"');");
}
</script>

and call it like so on an onclick event on a input box or something:

<input id="Pod_ID" onclick="popUp("http://yourwebsite.com/",600,400,200,200,);" type="text" />

-odobo

Thanks a lot odobo.
It's working.
But I can't understand the coding.
Could u plz explain about pop up messages some more.......???

Thanx n Regards
Yas.
Feb 26 '08 #3

P: 11
hey yasmine...
no problem..
I wrote the function popUp, it accepts many parameters...
the only crutial ones that you need to supply are the first 5..
as follows:
1. the url to open in a pop up.
2. the width you want the pop up
3. the height you want the pop up
4. the location from the left of the screen in pixels
5. the location from the top of the screen in pixels.
now the rest of the parameters accept a 1 or a 0...
6. weather to show the toolbar on the pop up 1=yes 0=no
7. weather the user can resize the window 1=yes 0=no
8. weather to show scrollbars on the popup 1=yes 0=no
9. weather to show the menu bar on the popup 1=yes 0=no
10. weather to show the status bar on the popup 1=yes 0=no..
and oops!! 11 is wrong... at the end of this i will post code for that function again.. just replace with this new code.

so getting to the code...
when the function first starts executing, I am validating what was passed into the function and ensuring some default values..
like so..
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
- this is called shorthand... it basically is an either or.
toolbar = if toolbar is null or if toolbar = "" then toolbar = 1. otherwise toolbar equals itsself - in other words dont change anything.
you could write the same thing like this...
if(toolbar==null)
{
toolbar = 1;
}else if(toolbar=="")
{
toolbar = 1;
}else
{
// dont do anything here... toolbar has a value.
}


now the next two lines have the purpose of generating an id.
this is not real necessary. but sometimes I will want to access the window i have created from another window so an id helps out.
the id is created from the time property of javascripts date object which is well the time that it is ..ie.. 12:41am.

and finally the last line in the function is where we actually create the new window. we use an eval function which is not important you are welcome to google that.. and we use the function create from the window object. which we then pass in all the parameters to tell it how to open.

the only other part of this is just using our simple function..
we can put the simple line of javascript code on any user control like the text box inside any kind of event handler like the onclick event that we used... you could put it inside an onkeydown event if you wanted to... in fact you dont have to put it in any control or handler really, you can put it anywhere that the code will execute. like just underneath the function outside of the braces of coarse..
[inside the braces would create a nasty loop opening up many pop-ups and that would be no fun] and it will pop up a window when the code executes as the page loads.

here is the revised function...

function popUp(URL,Width,Height,Left,Top,Toolbar,Resizeable ,ScrollBars,
MenuBar,StatusBar)
{
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
ScrollBars = ScrollBars==null||ScrollBars==""?1:ScrollBars;
MenuBar = MenuBar==null||MenuBar==""?1:MenuBar;
StatusBar = StatusBar==null||StatusBar==""?1:StatusBar;
day = new Date();
id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id
+ "', 'toolbar="+Toolbar+",scrollbars="+ScrollBars+",loc ation=1,
statusbar="+StatusBar+",menubar="+MenuBar+",resiza ble="+
Resizeable+",width="+Width+",height="+Height+",lef t="+Left+",top="+Top+"');");
}

hope this helps ;)
-odobo

Thanks a lot odobo.
It's working.
But I can't understand the coding.
Could u plz explain about pop up messages some more.......???

Thanx n Regards
Yas.
Feb 26 '08 #4

P: 65
hey yasmine...
hope this helps ;)
-odobo
Thank u very much odobo.
So kind of u....
Now i understood clearly about pop up......
Thanx a lot........
Feb 26 '08 #5

nomad
Expert 100+
P: 664
hey yasmine...
no problem..
I wrote the function popUp, it accepts many parameters...
the only crutial ones that you need to supply are the first 5..
as follows:
1. the url to open in a pop up.
2. the width you want the pop up
3. the height you want the pop up
4. the location from the left of the screen in pixels
5. the location from the top of the screen in pixels.
now the rest of the parameters accept a 1 or a 0...
6. weather to show the toolbar on the pop up 1=yes 0=no
7. weather the user can resize the window 1=yes 0=no
8. weather to show scrollbars on the popup 1=yes 0=no
9. weather to show the menu bar on the popup 1=yes 0=no
10. weather to show the status bar on the popup 1=yes 0=no..
and oops!! 11 is wrong... at the end of this i will post code for that function again.. just replace with this new code.

so getting to the code...
when the function first starts executing, I am validating what was passed into the function and ensuring some default values..
like so..
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
- this is called shorthand... it basically is an either or.
toolbar = if toolbar is null or if toolbar = "" then toolbar = 1. otherwise toolbar equals itsself - in other words dont change anything.
you could write the same thing like this...
if(toolbar==null)
{
toolbar = 1;
}else if(toolbar=="")
{
toolbar = 1;
}else
{
// dont do anything here... toolbar has a value.
}


now the next two lines have the purpose of generating an id.
this is not real necessary. but sometimes I will want to access the window i have created from another window so an id helps out.
the id is created from the time property of javascripts date object which is well the time that it is ..ie.. 12:41am.

and finally the last line in the function is where we actually create the new window. we use an eval function which is not important you are welcome to google that.. and we use the function create from the window object. which we then pass in all the parameters to tell it how to open.

the only other part of this is just using our simple function..
we can put the simple line of javascript code on any user control like the text box inside any kind of event handler like the onclick event that we used... you could put it inside an onkeydown event if you wanted to... in fact you dont have to put it in any control or handler really, you can put it anywhere that the code will execute. like just underneath the function outside of the braces of coarse..
[inside the braces would create a nasty loop opening up many pop-ups and that would be no fun] and it will pop up a window when the code executes as the page loads.

here is the revised function...

function popUp(URL,Width,Height,Left,Top,Toolbar,Resizeable ,ScrollBars,MenuBar,
StatusBar)
{
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
ScrollBars = ScrollBars==null||ScrollBars==""?1:ScrollBars;
MenuBar = MenuBar==null||MenuBar==""?1:MenuBar;
StatusBar = StatusBar==null||StatusBar==""?1:StatusBar;
day = new Date();
id = day.getTime();

eval("page" + id + " = window.open(URL, '" + id
+ "', 'toolbar="+Toolbar+",scrollbars="+ScrollBars+",loc ation=1,s

tatusbar="+StatusBar+",menubar="+MenuBar+",resizab le="+
Resizeable+",width="+Width+",height="+Height+",lef t="+Left+",
top="+Top+"');");
}

hope this helps ;)
-odobo
You should see you can post this in the Howtos section.

nomad
Feb 26 '08 #6

P: 11
yas-
glad that helped.
-odobo

You should see you can post this in the Howtos section.

nomad
Feb 26 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.