Click to See Complete Forum and Search --> : Javascript between to Windows
pumbaa
03-10-2004, 07:41 AM
Hello together,
i've got a script that lists a directory tree. What i want is, to put this directory tree in a popup.
When selecting an Entry within the popup i like to pass the value of an text field in the windows, the popup was called from.
The script is already working, but at the moment started with the other page in a 2-section-divided frame. So what i need to know:
How can i change the value from textfield "txt2" within the base-site out of to popup to any value?
Thank a lot
Pumbaa
pumbaa
03-10-2004, 08:10 AM
opener.document.getElementById("txt2").value = "blabla";
THX
olerag
03-10-2004, 08:47 AM
From your text not sure which way your going; parent->child
or child->parent. Here's both ways..
Parent
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Parent/Child Comm Sample</title>
<script type="text/javascript">
var newWin="";
function setHidden(val) {
document.forms[0].hide1.value = val;
if (val == "Y")
alert("Submit Form");
else
alert("Did not agree");
}
function getRadioValue(name) {
var s = "script";
newWin = window.open('agree.htm','','top=150,left=150,width=325,height=300');
}
function copyToChild(val) {
if (!newWin.closed && !newWin == "") {
newWin.document.forms[0].popField1.value = val;
}
}
</script>
<p style="text-align: center;">
Parent/Child Comm Sample
</p>
<form action="#">
<input type="hidden" name="hide1" />
<p>
<input type="text" name="field1" size="20" onBlur="copyToChild(this.value)" />
</p>
<p style="text-align: center;">
<input type="button" value="Submit" onClick="getRadioValue('Agreement Window')" />
</p>
</form>
Child
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Pop-up Sample</title>
<script type="text/javascript">
function passRadioValue(form) {
if (form.rg1[0].checked) {
window.opener.setHidden("Y");
}
else {
window.opener.setHidden("N");
}
self.close();
}
</script>
<p style="text-align: center;">
Child Pop-up
</p>
<form action="#">
<p>
<input type=radio name=rg1 value=Y>Agree<br>
<input type=radio name=rg1 value=N>Do Not Agree
</p>
<p>
<input type="text" name="popField1" size="20" />
</p>
<p style="text-align: center;">
<input type=button value=Submit onClick="passRadioValue(this.form)">
</p>
</form>