Submit Javascript Pop-up from main page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeschafe
    New Member
    • Dec 2008
    • 6

    Submit Javascript Pop-up from main page

    Hi I'm developing in Oracle Application Express and I want to put a link on one of my pages that opens a pop-up of a different php page using javascript.

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function popitup(url) {
         newwindow=window.open(url,'name','height=500,width=500,  
                           scrollbar=yes,resizable=yes,directories=yes, 
                           toolbar=yes,statusbar=yes,menubar=yes');
         if (window.focus) {newwindow.focus(); }
         return false;
    }
    //-->
    </script>
    
    
    
    <a href="http://blah.php" onclick="return popitup('http://blah.php')"
    	>Link to popup</a>

    That's just the simple pop-up portion, but what i want to do is submit a form on that new php pop-up page right after the user clicks on the link.

    Is this possible?

    Thanks Jeff
  • clain
    New Member
    • Feb 2007
    • 79

    #2
    sure you can do it... let a page submit be called on page load. or set a timer of say 2 seconds to submit the form

    Comment

    • jeschafe
      New Member
      • Dec 2008
      • 6

      #3
      Hey thanks for the quick reply!

      While that is what I need to do, I need to call the submit from the main oracle apex page, not from the popped-up php page. I don't know if it is possible to submit a pop-up page from another page?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You can submit the form from the parent page from the popup by referring to the parent window from the child window, e.g.
        Code:
        window.opener.document.getElementById("formid").submit();

        Comment

        • jeschafe
          New Member
          • Dec 2008
          • 6

          #5
          Thank you Acoder for your reply, but that is still not quite what I want to do, let me see if I can expalin the scenario a little better.

          I have a main page. This main page contains a link which calls a javascript function to create a new pop-up window.

          On this pop-up window, there is a text field for a part item, and a submit button. I want to be able to put a value from my main page into the pop-up text field and then submit the pop-up. This pop-up window though is not on the same website, it's to a different site.

          Ideally it would be something like this..

          Code:
          function popitup(url) {
                newwindow=window.open(url,'name','height=500,width=500,  
                                   scrollbar=yes,resizable=yes, directories=yes, 
                                   toolbar=yes,statusbar=yes,menubar=yes');
                if (window.focus) {
                    newwindow.focus();
                }
          
               newwindow.document.getElementById('searchNumber').value='300';
               newwindow.document.getElemetnById('searchNumberForm'.submit('go'); 
                  
               
          	return false;
          }
          1) Still the main question is this even possible or something like this?

          2) My link looks like this...

          Code:
              <a href="blahsite.php" onclick="return popitup('blahsite.php')">
              Link to popup</a>

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            If the form page in the popup is on a different site, then it won't be possible unless you serve the page from your domain.

            If it's from the same domain, what you can do is in the onload of the popup, get the value from the parent using parent.opener, set the value of the text field and then submit from the popup. The reason you have to do it in the pop-up onload is that the window is not available immediately. You could use a timeout, but that assumes that it will be opened and loaded in that time.

            Comment

            • jeschafe
              New Member
              • Dec 2008
              • 6

              #7
              Ok I was afraid of that. The pop-up page is of a different server, I'm not sure about the domain though. If it was on the same domain could it be done then?

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                Yes, it can be done. If you're using server-side code, you could serve the cross-site page from your domain.

                Comment

                • clain
                  New Member
                  • Feb 2007
                  • 79

                  #9
                  i have an alternate idea... why not we use Query String for the same?? rather than posting the pop up page use a query string..

                  pass the Query string to pop up as query string and also on submitting you can use a query string back to return the value.

                  it will be good to have a server side technology such as PHP,JSP,ASP. to get the things easier(i mean to get the query string variables easily ) ...

                  You can also do the same with java script.!!!!

                  Jeff, if you need more clarification on how to do it? please do post back .. so that we can help more..

                  enjoy

                  Comment

                  • jeschafe
                    New Member
                    • Dec 2008
                    • 6

                    #10
                    To Acoder:

                    I'm sorry if I do not quite understand, but what is "serving the cross site page from your domain?" How would you implement this, is there any way you could give me an example or some resource to read up on?




                    To Clain:

                    The only problem with the querystring idea is that I do not have access to the page that is being popped up. It is on a different server, it is using PHP, but I do not know how to pass it the correct value as a querystring.

                    Let me explain a little further....

                    This PHP site has a big list of part numbers, and at the top it has a "Search By Number" form. I basically just want to insert a part number into the text box in that "Search By Number" form and submit that form, which will return a pdf of that part.


                    Thanks for all of your help so far.

                    Comment

                    • acoder
                      Recognized Expert MVP
                      • Nov 2006
                      • 16032

                      #11
                      Originally posted by jeschafe
                      I'm sorry if I do not quite understand, but what is "serving the cross site page from your domain?" How would you implement this, is there any way you could give me an example or some resource to read up on?
                      For example, you could use Curl. There's also a library in PHP for Curl.

                      Originally posted by jeschafe
                      The only problem with the querystring idea is that I do not have access to the page that is being popped up. It is on a different server, it is using PHP, but I do not know how to pass it the correct value as a querystring.
                      You don't need access to the page if you pass in the value when opening the popup, e.g.
                      Code:
                      window.open("popup.php?val=" + encodeURIComponent(document.getElementById("id").value),"win");

                      Comment

                      • jeschafe
                        New Member
                        • Dec 2008
                        • 6

                        #12
                        Originally posted by acoder
                        You don't need access to the page if you pass in the value when opening the popup, e.g.
                        Code:
                        window.open("popup.php?val=" + encodeURIComponent(document.getElementById("id").value),"win");

                        Right, I understand that portion, my problem is I don't know what they call "val" as part of their php page.


                        This "pmd.php?bb=0&p mdQsa=a16041475 ede60a4d44b1c81 9049abe6" is the query string portion of the url that comes up when searching for part number 6735350. It should be something simple like "pmd.php?partNu m=6735350". But instead it's all that garbage which makes me think they are encoding it or something.

                        Is it still possible to do at all?

                        Thanks,
                        Jeff

                        Comment

                        • acoder
                          Recognized Expert MVP
                          • Nov 2006
                          • 16032

                          #13
                          Yes, it does seem like that. How is it converted to the other value? Do you have permission from the website owner to use their site in this way? If so, you can use whatever is used to convert to submit to the page, or use PHP Curl to get the contents of the page from the site.

                          Comment

                          Working...