Skip to content Skip to sidebar Skip to footer

How To Pass Values From Pop Up Window To Parent Window Through Jquery In MVC

i have three buttons in my view page says 'Button1', 'Button2' & 'Button3' and i have three TextBoxes corresponds to each button says 'TextBox1','TextBox2' & 'TextBox3' . W

Solution 1:

Give an id to the textboxes (for example textBox1), then try this..it's a simple JavaScript.
You don't need jQuery for this.

window.opener.document["nameForm"].getElementById("textBox1 ").value = "your some values will go here"

Solution 2:

We can do this by using jquery OR Javascript. here we are going to discuss with email id updates.

in bellow example a pop up window will open with auto fill email id from parent window. after update, a email will automatically update in parent window text box and pop up window will have closed autocratically.

Example:

1) Create file index.html as a parent windows

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<title></title>
<head></head>

<body>
<table>

<tr>
<td colspan=”2″>Example for update email id.</td>
</tr>
<tr>
<td>Email Id:</td>
<td>
<input type=’text’ name=”emailID” id=”emailId” value=”demo@demo.com”></td>
</tr>
<tr>
<td>
<input type=”button” name=”update” value=”Update”
onClick=’window.open(“update_popup.html”, “”, “width=400, height=300″)’>
</td>
</tr>
</table>
</body>
</html> 

2) Create file update_popup.html as a pop up window where email id auto fill from parent window for update.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<html>
<title></title>
<head></head>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js”></script>
<script>
$(document).ready(function(){

//== pre fill parent window email id in popup window for update

var emailId = window.opener.document.getElementById(“emailId”).value;
$(“#emailId”).val(emailId);

//=== update updated email id in to parent window

$(“#Save”).on(‘click’,function(){

var updated_emailId = $(“#emailId”).val();
window.opener.document.getElementById(“emailId”).value = updated_emailId;
window.close();
});
});
</script>

<body>
<table>
<tr>
<td>Email Id:</td>
<td>
<input type=’text’ name=”emailID” id=”emailId” value=””></td>
</tr>
<tr>
<td><input type=”button” name=”Save” id=”Save” value=”Save”></td>
</tr>
</table>
</body>
</html>

for more click on.

http://www.delhincrjob.com/blog/how-to-get-the-parent-window-element-value-in-popup-window-using-jquery/


Post a Comment for "How To Pass Values From Pop Up Window To Parent Window Through Jquery In MVC"