How to return the value of modal dialog window to text area?

KJungle
KJungle used Ask the Experts™
on
Hello,
I was wondering how to return the value selected in a modal dialog window to the text area of an IFrame, with javascript?
Many thanks in advance
Kenny
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Modal dialogs have a property called returnValue (case sensitive as always). This property is fully js type supported and can hold complex types such as objects, arrays etc.

Dont try and put in a reference to an object in your modal dialog box though.

The method showModalDialog returns whatever was put into the returnValue property.

eg/ caller.htm

var retval = window.showModalDialog("dialog.htm");

eg/ dialog.htm

window.returnValue = document.forms["myform"].elements["mytextarea"].value;

Hope this makes sense. Heres a URL which should help makes things bit more clearer/detailed.

Author

Commented:
Hey thanks worldspawn,
So, for me to return the value from a Modal(dialog.htm) to an Iframe (iView) on an HTML page then, it would go like this;
<-- html page --->
<html>
<head>
<SCRIPT>
function doModal()
{
var retval = window.showModalDialog("dialog.htm"+"attributes");
}
</SCRIPT>
</head>
<body>
<input onClick="doModal()"></input>
<-- inline frame text area -->
<iframe id="iView" trusted="yes" style="width: 775px; height:420px" border="1"></iframe>
<-- inline frame text area -->
</body>
</html>

<-- Modal Window (dialog.htm)--->
<html>
<head>
<SCRIPT>
function bgColor()
{
window.returnValue = document.iView.bgColor.value;
}
</SCRIPT>
<body>
<select name="backcolor" onChange="bgColor(this.options[this.selectedIndex].value)">
<option value="<style>BODY{background-color:#FF0000}</style>">RED</option>
</body>
</html>

What I am trying to do is allow the user to define the BG color of the rich text edit area that is made by the iFrame.
This is what I am going to try next.

Thanks a lot again for your help,
Kenny

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial