By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Can this be done in JavaScript ?

P: n/a
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. In addition both the tables are located in different
frames of a HTML page. So my question is can such an update be done ?
Is it necessary that the tables be located in the same frame for the
update to work ? Any pointers would be appreciated ?

Thanks,
-P.
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
In article <7a**************************@posting.google.com >,
nm******@yahoo.com enlightened us with...
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. In addition both the tables are located in different
frames of a HTML page. So my question is can such an update be done ?
Is it necessary that the tables be located in the same frame for the
update to work ? Any pointers would be appreciated ?

Thanks,
-P.


It can be done IF:
All browsers using it are DOM compliant.
All browsers using it have javascript enabled.
All relevant frames come from the same domain and use the same protocol (http
or https, but both the same).

--
--
~kaeli~
He had a photographic memory that was never developed.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2

P: n/a
Thanks Kaeli.

-P.

kaeli <ti******@NOSPAM.comcast.net> wrote in message news:<MP************************@nntp.lucent.com>. ..
In article <7a**************************@posting.google.com >,
nm******@yahoo.com enlightened us with...
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. In addition both the tables are located in different
frames of a HTML page. So my question is can such an update be done ?
Is it necessary that the tables be located in the same frame for the
update to work ? Any pointers would be appreciated ?

Thanks,
-P.


It can be done IF:
All browsers using it are DOM compliant.
All browsers using it have javascript enabled.
All relevant frames come from the same domain and use the same protocol (http
or https, but both the same).

--

Jul 23 '05 #3

P: n/a
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, "&amp;").replace(
/</g, "&lt;").replace(
/>/g, "&gt;").replace(
/ /g, "&nbsp;");
}
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>
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.