PDA

View Full Version : DHTML Window widget to pass back value



MacAries
10-11-2007, 08:46 PM
1) Script Title: (v1.03)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm

3) Describe problem: I open testme.asp in DHTML Window widget from testbatch.asp I want testme.asp to enter selected value in textbox of parent page testbatch.asp:confused:

It would be really nice if widget would close and put the value in the textbox when submit is pressed in form control

MacAries
10-11-2007, 10:21 PM
Tried to use some javascript in widget:
<script language="JavaScript">
function sendBack(value) {
this.opener.document.main.EMP1.value = value;
this.close();
</script>

<a href="javascript:sendBack('One')">One</a>

The parent has form name="main" and target input type="text" name="EMP1"

but it's not working

ddadmin
10-11-2007, 11:56 PM
You wouldn't use "this.opener", but "parent" instead, inside your script. For example:


<form id="testform">
<input type="text" id="mybox" />
</form>

var googlewin=dhtmlwindow.open("googlebox", "iframe", "test.htm", "#1: Test", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")

Here's the source for "test.htm":


<script type="text/javascript">

function postback(thevalue){
parent.document.getElementById("mybox").value=thevalue
}

</script>

<form>
<input type="text" id="test" /> <input type="button" value="Save" onClick="postback(document.getElementById('test').value)" />
</form>

MacAries
10-17-2007, 12:33 PM
That was it! Now works like a charm. Thanks so much. :)
OK now looking around to see how to close the DHTML widget window.close is not supported:confused:

MacAries
10-17-2007, 01:00 PM
This works:
<input type="button" value="CLOSE" name="exit" onClick="javascript:parent.closeit()">