Click to See Complete Forum and Search --> : Passing Variables Through A Dialog Window
tarran
09-04-2003, 09:14 PM
Hi All,
I'm trying to pass some variables from a few input boxs in a dialog window to a underlying window of which I want the variables to go into a textarea.
Could some one shed some light on how to do this please?
Any help is appreciated.
Kind Regards,
Tarran Walker
What do you mean "dialog window"? Doesn't sound like JavaScript to me...Perhaps you are looking for Java? Or, do you mean showModalDialog for IE?
tarran
09-04-2003, 09:34 PM
Sorry!, I Did mean using the showModalDialog in IE.
Hmm... with showModalDialog I'm not sure if there is a way to pass values back to the opener. Why can't you just use a regular popup (which would allow you to use window.opener to reference the opener)
tarran
09-04-2003, 09:54 PM
I guess I can. How can I make the popup open in the middle of the screen regardless of resolutions?
I know these are more than likely stupid questions but I haven't done alot of client-side programming.
Take a look at http://www.webdevfaqs.com/javascript.php#centeredpopup...
tarran
09-04-2003, 10:15 PM
I am making a Basic WYSIWYG editor and I want to pass the values back into the element that the window opened from.
How can I get the popup window to pass the values back into the original element considering it has a dynamic name?
I hope thats clear.
Not sure exactly what you mean, but you can pass variable from the child to the parent like this: (assumes you want to fill out a variable on the parent window named "test")
window.opener.test = "some value";
tarran
09-04-2003, 11:22 PM
> window.opener.test
In this case test would be the element that you are parsing the infomation to but I can't name the element because the WYSIWYG Editor is a behavior stored in a HTC file. This is completly resuable file that can use unlimted names on the textarea.
I hope I have made sense out of this.
So my question is I guess.
How do I parse the information back to the textarea without having to use the textareas name?
If you know what their elements index is, your could try something like this:
window.opener.document.forms[0].elements[0].value = "some value";
That will set the first element in the form to have a value of "some value".
Webskater
09-05-2003, 09:34 AM
I don't know if this is relevant as your discussion has moved on from whether a modal window can communicate with its opener. It can. If you open a window thus:
window.showModalDialog('SuppContactWrapper.asp?SupplierID=' + SupplierID + '&Modal=true',window,'dialogHeight:400px; dialogWidth:600px; help:no; status:no;');
The modal window can commuicate with its opener thus.
<script language="javascript">
function close1(FirstName,Surname,WorkPhone,WorkFax,Email,CID)
{
var callerWindowObj = dialogArguments;
callerWindowObj.phone = WorkPhone;
callerWindowObj.fax = WorkFax;
callerWindowObj.email = Email;
callerWindowObj.firstname = FirstName;
callerWindowObj.surname = Surname;
callerWindowObj.cid = CID;
callerWindowObj.UpdateSelect();
window.close();
}
</script>
This function is obtaining a reference to the opener in the line
var callerWindowObj = dialogArguments
and passing some values passed into the function to variables on the opener and then executing a function on the opener which, in this case, updates the contents of a select box.
Apologies if this is irrelevant. Its probably IE only, but I only code for IE.
tarran
09-07-2003, 09:01 PM
Hi All,
Thanks for your help.
I ended up with:
var globalDoc = window.dialogArguments;
var grngMaster = globalDoc.selection.createRange();
grngMaster.pasteHTML('I will pass this text to the editor');
grngMaster.collapse(false);
grngMaster.select();
window.close();
Everyones help was very much appreciated.
Thanks once again.