You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Within showModalDialog, assuming your textboxes have IDs of "txtForename" and "txtSurname":
Code:
<body onbeforeunload="terminate();">
function terminate()
{
var o = new Object();
o.forename = document.getElementById("txtForename").value;
o.surname = document.getElementById("txtSurname").value;
window.returnValue = o;
}
If you do it like that you need to test the reurnValue to make sure it's not null which can happen if someone closes the modal dialog using a method other than the prescribed button, ALT+F4 for example.
hi
i am newbee to this forum
my problem is also same
above code given by rohit sharma is not working for me
i am unable get values from modaldialog to parent
plz help
actually this is the scenario
user should enter a value 2 times, after his first entry i dump that in to database and redirect to new page for 2nd entry. At 2nd entry it shud compare it with first entry, if it false then it shud popup with modal dialog showing first and second entry and asking him for correct entry and that value shud be passsed to 2nd entry page and that value be assigned to textbox value here I was able to do up correct entry but I was not able to pass correct entry textbox value from modal dialog to 2nd entry page textbox value
here is the code
"parent_args.html"
Code:
<html>
<head>
<title></title>
<script type="text/javascript">
function fnLaunch()
{
var aForm;
aForm = oForm.elements;
var myObject = new Object();
myObject.firstName = aForm.entry2.value;
// The object "myObject" is sent to the modal window.
window.showModalDialog("child_args.html", myObject, "dialogHeight:300px; dialogLeft:200px;");
}
</script>
</head>
<body>
<form id= "oForm" action="">
<input type="text" name="entry2" id="entry2" value="" maxlength="4" onchange="fnLaunch();" />
<br/>
</form>
</body>
</html>