Can this be done in JavaScript ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pentium77

    Can this be done in JavaScript ?

    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.
  • kaeli

    #2
    Re: Can this be done in JavaScript ?

    In article <7a449ecc.04100 40642.13a8fb5f@ posting.google. com>,
    nmadanku@yahoo. com enlightened us with...[color=blue]
    > 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.
    >[/color]

    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.



    Comment

    • pentium77

      #3
      Re: Can this be done in JavaScript ?

      Thanks Kaeli.

      -P.

      kaeli <tiny_one@NOSPA M.comcast.net> wrote in message news:<MPG.1bcb3 15d242d7d9198a1 a1@nntp.lucent. com>...[color=blue]
      > In article <7a449ecc.04100 40642.13a8fb5f@ posting.google. com>,
      > nmadanku@yahoo. com enlightened us with...[color=green]
      > > 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.
      > >[/color]
      >
      > 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).
      >
      > --[/color]

      Comment

      • Robert

        #4
        Re: Can this be done in JavaScript ?

        nmadanku@yahoo. com (pentium77) wrote in message news:<7a449ecc. 0410040642.13a8 fb5f@posting.go ogle.com>...[color=blue]
        > 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.[/color]

        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.
        [color=blue]
        > In addition both the tables are located in different
        > frames of a HTML page.[/color]
        [color=blue]
        > So my question is can such an update be done ?[/color]

        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.htm l"
        id="myframe1"
        name="nameframe 1"
        scrolling=yes>
        <frame src="frame2.htm l"
        id="myframe2"
        name="nameframe 2"
        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.fr ames['nameframe2'].changeText('in sert',
        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(span Id,text)
        {
        var node;
        /* Find the span node. */
        if (document.getEl ementById)
        {
        node = document.getEle mentById(spanId );
        }
        else if (document.all)
        {
        node = document.all[spanId];
        }
        else
        {
        alert("Construc ts document.getEle mentByID " +
        "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.repl ace(
        /&/g, "&amp;").replac e(
        /</g, "&lt;").replace (
        />/g, "&gt;").replace (
        / /g, "&nbsp;");
        }
        else if (node.appendChi ld &&
        document.create TextNode)
        {
        /* Since this is plan text, prevent multiple
        blanks from being compressed into one. */
        var theData = text.value.repl ace(/ /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.appendChil d(
        document.create TextNode(theDat a));
        }
        }
        else
        {
        alert("Function s 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>

        Comment

        Working...