Ventana emergente de JavaScript

I am currently working on a php e-mail system. I created a javascript pop-up page where I can add users (mail addresses). Now I want to post the selected user('s) from the javascript pop-up window to open the website of course I get the page where you want to post in the pop up to see.

Now I want to now, if there is click on the submit than close the popup and allows the data to the open web page whit post?

¿¿Cómo puedo hacer esto??

preguntado el 09 de marzo de 12 a las 15:03

3 Respuestas

you might want to look to the overlay plugin at herramientas jquery. Pop-ups are blocked by the browser most of the times. And imo an overlay is a more elegant solution. Furthermore, you can just post your form as you would normal do on a webpage, nu extra js needed there!

--- edit; when reading your question more closely; you don't even need to post the page! Just assign a click event to the submit button (which doesn't necessarily needs to be a submit button). In your event function you can read out the filled in addresses (or other information), paste it into the desired fields (whether it be a form field or just a regular div) and close the overlay again. Now you don't even need a page refresh!

respondido 09 mar '12, 16:03

You'll want to use AJAX to post the form asynchronously so the user doesn't have to wait for it to process or view the processing page. jQuery makes it very easy to use AJAX como se muestra aquí.

Also, after the work is done in the popup window you can access and refresh the parent window using the window.opener function:

<script language="JavaScript">
    function refreshParent() {
      window.opener.location.href = window.opener.location.href;
      window.close();
    }
</script>

respondido 09 mar '12, 15:03

But how can i after the refresh, get the posted vars? - Raymond van Os

@RaymondvanOs Do you need access to the vars in the parent page, the popup page, or the page being posted to from the popup? - CFL_Jeff

    <script>
        $("a[href=#myModal]").click(function() {
            var str = $(this).attr("data-phpvar");
            var substr = str.split('||');

            $("[name=textinput1]").val(substr[0]);
            $("[name=textinput2]").val(substr[1]);
        });
    </script>

   <form>
        <table>
            <tr>
                <td>
                    <a href="#myModal" title="#" role="button" data-toggle="modal" data-phpvar="<?php echo $value['something'] . '||' . $value['something']);?>"></a>
                </td>
            </tr>
        </table>
    </form>

OnClick of the href link or button you will send the data-php-var to the jQuery function. This function will send the values into the popup. In the popup is a text-field with the same name the jQuery function will put your values into de field.

Respondido el 30 de diciembre de 13 a las 19:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.