spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column90


Modal and Modeless Dialog Boxes

Developer News
iPhone Users Just Want to Have Fun
Oops! I Fixed the Linux Kernel
Jim Zemlin: The New Center of Linux Gravity

Passing Objects to the Dialog Box

A more powerful way to pass information between the caller and the callee is through an object. You can pass properties from the caller to callee and back from the callee to the caller. You can also define the object's methods within the caller and use them within the callee. In fact, you can pass the caller window object to the callee. in this way, you ensure the callee has access to the caller's variables and functions.

Let's see an example. Our caller invokes the callee to prompt the user for his or her favorite color. The color is communicated back to the caller via the caller's update() function. First, play around with the scripts. Here is the caller:

<HTML>
<HEAD>
<TITLE>DialogArguments Example</TITLE>
<SCRIPT>
var sColor="";

function callDialog() {
 showModelessDialog("callee.html",window,"status:false;
  dialogWidth:300px;dialogHeight:150px");
}

function update()
{
  oColor.innerText = sColor;
}
</SCRIPT>
</HEAD>
<BODY>
<P>Enter your favorite color: <SPAN ID="oColor"
STYLE="color:red;font-size:24">Yellow</SPAN></P>
<INPUT TYPE="button" VALUE="Display Modeless Dialog"
  onclick="callDialog()">
</BODY>
</HTML>

The favorite color field, oColor, is initialized to Yellow. When you click the Display Modeless Dialog button, the function callDialog() kicks in and calls showModelessDialog(). Notice the function call's second parameter: window. We pass the user's favorite color as the window object property.

Next: How to update the caller application from its dialog box

http://www.internet.com



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Performance Optimizations for High Speed JavaScript · Advanced Web Performance Optimization · Simple Comments Meets OpenID
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Installing Oracle E-Business Suite R12 on Windows 2003 · When the Cloud Storms on You · eBay Watch: DSR 4.3 Tips, Tactics and Seller POV


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: August 13, 2001
Revised: August 13, 2001

URL: http://www.webreference.com/js/column90/8.html