nm******@yahoo.com (pentium77) wrote in message news:<7a**************************@posting.google. com>...
Basically I have a situation where I need to update changes occuring
in one Text field of a table into another text field located in
another table.
How does the text field change in the first table?
If you are already changing text in the first frame, all you have to
do is find the node in the table in the second frame and you can use
the same code to change the text in the second frame.
In addition both the tables are located in different
frames of a HTML page.
So my question is can such an update be done ?
I'll change some text in a table in another frame.
The tag id needs to be unique. Make certain that you do not have name
conflicts in IE.
With MacOS 10.2.6, I tested these in IE 5.2, Safari 1.0, and Netscape
7.2.
Robert
frames.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Frames Layout</title>
</head>
<frameset rows="45%,55%" >
<frame src="frame1.html"
id="myframe1"
name="nameframe1"
scrolling=yes>
<frame src="frame2.html"
id="myframe2"
name="nameframe2"
scrolling=yes>
</frameset>
</html>
frame1.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>insert some text</title>
</head>
<body>
<p>Insert or change some text.
<br>
Don't forget to see what happens when you
press the button more than once.</p>
<form name="myForm">
<input type="text" name="total" size="20">
<br><br>
<input type="button"
name="activate"
value="change the text"
onclick="top.frames['nameframe2'].changeText('insert',
document.forms['myForm'].elements['total']);">
<br>
</form>
</body>
</html>
frame2.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>frame 2</title>
<script type="text/javascript">
function changeText(spanId,text)
{
var node;
/* Find the span node. */
if (document.getElementById)
{
node = document.getElementById(spanId);
}
else if (document.all)
{
node = document.all[spanId];
}
else
{
alert("Constructs document.getElementByID " +
"and document.all are not available in this browser. " +
"You need to use a newer browser.");
return;
}
if (!node)
{
alert("You need to create a span tag with " +
"the id of " + spanId + ".");
return;
}
/* Insert the text. */
if (typeof node.innerHTML == "string")
{
/* Make innerHTML act like the simple text insert. */
node.innerHTML = text.value.replace(
/&/g, "&").replace(
/</g, "<").replace(
/>/g, ">").replace(
/ /g, " ");
}
else if (node.appendChild &&
document.createTextNode)
{
/* Since this is plan text, prevent multiple
blanks from being compressed into one. */
var theData = text.value.replace(/ /g, "\xA0");
/* If a node already exists, assume we
created it on a prior click by the user. */
var nextNode = node.firstChild;
if(nextNode)
{
/* Yes, replace the text. */
nextNode.data = theData;
}
else
{
/* No, Insert the new node. */
node.appendChild(
document.createTextNode(theData));
}
}
else
{
alert("Functions to insert text are not available. " +
"You need to use a newer browser.");
return;
}
}
</script>
</head>
<body>
<p>Text in this frame will be changed from frame 1.</p>
<table border="2">
<tr>
<td>
<p>Text in the cell below will be changed.</p>
</td>
</tr>
<tr>
<td>
<p>Change this "<span id='insert'></span>".</p>
</td>
</tr>
</table>
</body>
</html>