Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a view in which i have <input type="Button">, on the click of this button i want that new window/view will appear and it should display set of records (can be from database) and user may choose among set of data.
selected data should be populated back in calling view.
I am not sure which approach to take for this. please suggest.
Posted

This one works fine with internet explorer :

page1.html

XML
<html>
<head>
<script type="text/javascript">

function openscr()
{
    var scr = window.open("page2.html", "_blank", "toolbar=no, scrollbars=yes, resizable=yes,addressbar=no, width=350, height=300");
    timer = window.setInterval(function () { scr_closed(scr) }, 1000);
}

function scr_closed(scr) {
    if (scr.closed) {
        window.clearInterval(timer);

        document.getElementById("txtname").value= ret_val;

    }
}
</script>
</head>

<body>

<input type="text" id="txtname" />
<input type="button" value="Click me" onclick="openscr();"/>

</body>




page2.html

XML
<html>
<head>
<script type="text/javascript">
function return_values() {
    window.opener.ret_val = document.getElementById("myname").value;
    self.close();
    return false;
}
</script>
</head>

<body>

Enter Your Name <input type="text" id="myname" />
<input type="button" value="ok" onclick=" return return_values();"/>

</body>
 
Share this answer
 
v2
You can implement this with jquery also :


https://jqueryui.com/dialog/#modal-form[^]
 
Share this answer
 
Comments
preet88 3-May-15 17:52pm    
I have to populate a list of data that will fetched from database unlike in this solution where input is being provided by user.
please give me some pointer in that.
pparya27 5-May-15 8:08am    
Which server side programming language will you use?
you can fetch the data from database in page2, and write it in a javascript variable, or json object and use the above snippet to send that data back to page1.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900