Click to See Complete Forum and Search --> : Data islands


ShailendraSawan
02-08-2006, 08:04 AM
Hi,
I have a window [modal dialog] ,name it say A, which contains data island [DI]. There is a link on window A which opens window B. When i open window B i want to pass on the reference of data island to B. When i pass the reference of DI to B, i want to mark the state of DI. B might make some change in DI. If required i must be able to roll back to the marked state of DI.

Is it possible.

Regards,
Shailendra

CrazyMerlin
02-08-2006, 08:35 AM
Yes.

Instead of 'passing' the data from A to B, use a function on B to 'get' data from A.

In what form is DI? Is it an object, or simply a variable on A?

When B has DI, you can then make DC = DI (DC being set as DataConstant). Then if you wish to rollback, you simply say window.opener.document.getElementById('DI').value = DC.

Otherwise to commit the change onunload() of B you set window.opener.document.getElementById('DI').value = DI.

When DI is an object, it belongs to the 'document' of A. But when DI is a variable it belong as a sibling of 'document', and so belongs to 'window'.

So, to get a variable from A you would use: (in B)

var DI = window.opener.DI;

Here is a simple example of passing values via a variable.

parent.htm

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<script>
var strValue = "";

function openWindow(toWhere, w, h, s){
strValue = document.getElementById('thisText').value;
var strFeatures = 'width=' + w + ', height=' + h + ', status=0, menubar=0, toolbar=0, scrollbars=' + s + ', dialog=1';
var winX = window.open(toWhere, "CardForm", strFeatures);

}
</script>
</head>

<body onload="document.getElementById('thisText').value = new Date();">
<form name="thisForm">
<input type="button" value="open child" onclick="javascript: openWindow('child.htm',200,100,'no')"><br>
Parent Value: <input type="text" id="thisText" size="30" value="">
</form>
</body>

</html>


child.htm

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 2</title>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
</head>

<body>
<form>
<input type="button" value="get parent value" onclick="javascript: this.parentNode.elements['got'].value = window.opener.strValue;">
<br>
<input type="text" size="22" value="" name="got">
</form>
</body>

</html>


Just remember...if getting the value of an object property, use: window.opener.document.getElementById('idofobject').value; else if the value you want is a variable use: window.opener.nameofvariable

Hope that clear things up for you.

ShailendraSawan
02-08-2006, 09:42 AM
can we speak over yahoo phone!! i have mike and speakers attached. I think i would be able to explain the problem much better.

yahoo id: sawant_shail

CrazyMerlin
02-08-2006, 10:23 AM
sorry I don't have any yahoo software on my system.

you're welcome to email me at info@webtop-designs.com if you need to send code privately.

thanks.