Can jquery do this? popup for value

I used JavaScript to open a new window (child) when the user clicks a button from the parent window.

In a new window (child) I have a text field and a button, I need to get the value of the text field and go to the parent window, when the user clicks the button, closing the child window, I need an updated value inserted into the parent window (without updating the parent window) so I can display my value for some hidden field / label of the parent window, how can I do this?

1 parent window has a button, an open child window 2-child window has a text field and a button, when the button is pressed, the child will send a message to the server to update the database, and then transfer the value of the text field to the parent window without updating the parent window and close the child window .

How can i do this? Can this be done using simple JavaScript? If I do this using jquery, will I have more benefit? Can anyone advise how I can do this?

+6
javascript jquery popup
source share
2 answers

I would suggest using the jQuery dialog widget instead of the actual new window. This will simplify access to the new value, as in the same DOM window. Just call back from the button that closes the window, extract the value from the DOM element contained in the dialog box, and copy it to the target DOM element in the form.

$('#popupDialog').dialog({ modal: true, autoOpen: false, buttons: { 'Cancel': function() { $(this).dialog('close'); }, 'Accept': function() { $('#mainForm input#target').val( $(this).find('#widgetName').val() ); $(this).dialog('close'); } }); $('#popupButton').click( function() { $('#popuDialog').dialog('open'); }); <div id="popupDialog" title="Input a new widget name"> <p> <label for="widgetName">Please input a new widget name:</label> <input type="text" id="widgetName" /> </p> </div> 
+14
source share

Absolutely: you are looking for a native open source JS property (discussion here ), without jquery (although it can be wrapped for you there).

Opening and closing Windows is a pretty simple way to do something wrong, would you rather not have a lightbox or similar HTML embedded dialog on the page? The jQuery dialog will certainly be directed towards this.

* good; supported everywhere if standards are not defined

+4
source share

All Articles