pop up messages in php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • yasmine
    New Member
    • Feb 2008
    • 64

    pop up messages in php

    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
  • odobo
    New Member
    • Feb 2008
    • 11

    #2
    -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:
    Code:
    <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+",location=1,statusbar="+
    StatusBar+",menubar="+MenuBar+",resizable="+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
    Enclose your code within the appropriate code tags!! - moderator
    Originally posted by yasmine
    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
    Last edited by ronverdonk; Feb 26 '08, 04:08 PM. Reason: code within tags

    Comment

    • yasmine
      New Member
      • Feb 2008
      • 64

      #3
      Originally posted by odobo
      -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="javascrip t">
      function popUp(URL,Width ,Height,Left,To p,Toolbar,Resiz eable,ScrollBar s,MenuBar,
      StatusBar,Resiz eable) {
      Toolbar = Toolbar==null|| Toolbar==""?1:T oolbar;
      Resizeable = Resizeable==nul l||Resizeable== ""?1:Resizeable ;
      ScrollBars = ScrollBars==nul l||ScrollBars== ""?1:ScrollBars ;
      MenuBar = MenuBar==null|| MenuBar==""?1:M enuBar;
      StatusBar = StatusBar==null ||StatusBar=="" ?1:StatusBar;
      Resizeable = Resizeable==nul l||Resizeable== ""?1:Resizeable ;
      day = new Date();
      id = day.getTime();
      eval("page" + id + " = window.open(URL , '" + id + "', 'toolbar="+Tool bar+",scrollbar s="+ScrollBars+ ",location= 1,
      statusbar="+Sta tusBar+",menuba r="+MenuBar+",r esizable="+Resi zeable+
      ",width="+Width +",height="+Hei ght+",left="+Le ft+",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,2 00,);" 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.

      Comment

      • odobo
        New Member
        • Feb 2008
        • 11

        #4
        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:T oolbar;
        - 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==nul l)
        {
        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,To p,Toolbar,Resiz eable,ScrollBar s,
        MenuBar,StatusB ar)
        {
        Toolbar = Toolbar==null|| Toolbar==""?1:T oolbar;
        Resizeable = Resizeable==nul l||Resizeable== ""?1:Resizeable ;
        ScrollBars = ScrollBars==nul l||ScrollBars== ""?1:ScrollBars ;
        MenuBar = MenuBar==null|| MenuBar==""?1:M enuBar;
        StatusBar = StatusBar==null ||StatusBar=="" ?1:StatusBar;
        day = new Date();
        id = day.getTime();

        eval("page" + id + " = window.open(URL , '" + id
        + "', 'toolbar="+Tool bar+",scrollbar s="+ScrollBars+ ",location= 1,
        statusbar="+Sta tusBar+",menuba r="+MenuBar+",r esizable="+
        Resizeable+",wi dth="+Width+",h eight="+Height+ ",left="+Left+" ,top="+Top+"'); ");
        }

        hope this helps ;)
        -odobo

        Originally posted by yasmine
        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.

        Comment

        • yasmine
          New Member
          • Feb 2008
          • 64

          #5
          Originally posted by odobo
          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........

          Comment

          • nomad
            Recognized Expert Contributor
            • Mar 2007
            • 664

            #6
            Originally posted by odobo
            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:T oolbar;
            - 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==nul l)
            {
            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,To p,Toolbar,Resiz eable,ScrollBar s,MenuBar,
            StatusBar)
            {
            Toolbar = Toolbar==null|| Toolbar==""?1:T oolbar;
            Resizeable = Resizeable==nul l||Resizeable== ""?1:Resizeable ;
            ScrollBars = ScrollBars==nul l||ScrollBars== ""?1:ScrollBars ;
            MenuBar = MenuBar==null|| MenuBar==""?1:M enuBar;
            StatusBar = StatusBar==null ||StatusBar=="" ?1:StatusBar;
            day = new Date();
            id = day.getTime();

            eval("page" + id + " = window.open(URL , '" + id
            + "', 'toolbar="+Tool bar+",scrollbar s="+ScrollBars+ ",location= 1,s

            tatusbar="+Stat usBar+",menubar ="+MenuBar+",re sizable="+
            Resizeable+",wi dth="+Width+",h eight="+Height+ ",left="+Left+" ,
            top="+Top+"');" );
            }

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

            nomad

            Comment

            • odobo
              New Member
              • Feb 2008
              • 11

              #7
              yas-
              glad that helped.
              -odobo

              Originally posted by nomad
              You should see you can post this in the Howtos section.

              nomad

              Comment

              Working...