Pass html form data in bi-directional ways

Discussion in 'HTML' started by Matt, Mar 6, 2004.

  1. Matt

    Matt Guest

    I have 2 html pages, both have a text box and a button. In page1.html,
    when the user enter a text in text box, and click button, it will pass
    the form data to page2.html, and it will open page2.html in a smaller
    window and that data will show in text box in page2.html. In
    page2.html, if the user changes the text box data and click the
    button, it will update the data in existing window for page1.html. In
    other words, data can transfer back and forth in page1.html and
    page2.html.

    I already wrote the html pages as shown below. However, after clicking
    the button in page1.html, the data can be shown in text box in
    page2.html,
    But when user changes the text box data in page2.html, it will open
    another window for page1.html, not change the data in existing window
    for page1.html, and data cannot shown in new window for page1.html
    also.
    I am just using regular button, and i am not using submit button.

    any ideas? Please advise. Thanks!

    -------------- page1.html ----------------------------
    <html>
    <head>
    <script>
    function openwindow()
    { var myObject = new Object();
    myObject.firstName = fname.value;
    alert(myObject.firstName);
    var sReturn = window.showModalDialog("page2.html", myObject,
    "menubar=no, titlebar=no, toolbar=no, location=no, directories=no,
    status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes,
    width=400, height=500");
    }
    function window_onload()
    { alert("window onload...");
    if (window.dialogArugments != null)
    {
    alert("window.dialogArguments != null");
    var oMyObject = window.dialogArguments;
    fname.value = oMyObject.firstName;
    }
    else
    { alert("window.dialogArguments = null");
    }
    }
    </script>
    </head>
    <body onload="window_onload()">
    <H2>Page 1</H2>
    <P>name: <input type="text" name="fname">
    <P><input type="button" value="validate" onclick="openwindow()">
    </body>
    </html>


    ------------------------ page2.html --------------------------
    <html>
    <head>
    <script>
    function openwindow()
    { var myObject = new Object();
    myObject.firstName = fname.value;
    alert(myObject.firstName);
    var sReturn = window.showModalDialog("page1.html", myObject,
    "menubar=no, titlebar=no, toolbar=no, location=no, directories=no,
    status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=yes,
    width=400, height=500");
    }
    function window_onload()
    { alert("window onload...");
    // if (window.dialogArugments != null)
    // {
    // alert("window.dialogArguments != null");
    var oMyObject = window.dialogArguments;
    fname.value = oMyObject.firstName;
    // }
    // else
    // { alert("window.dialogArguments = null");
    // }
    }
    </script>
    </head>
    <H2>Page 2</H2>
    <body onload="window_onload()">
    <P>name: <input type="text" name="fname">
    <P><input type="button" value="validate" onclick="openwindow()">
    </body>
    </html>
     
    Matt, Mar 6, 2004
    #1
    1. Advertising

  2. Matt

    SpaceGirl Guest

    "Matt" <> wrote in message
    news:...
    > I have 2 html pages, both have a text box and a button. In page1.html,
    > when the user enter a text in text box, and click button, it will pass
    > the form data to page2.html, and it will open page2.html in a smaller
    > window and that data will show in text box in page2.html. In
    > page2.html, if the user changes the text box data and click the
    > button, it will update the data in existing window for page1.html. In
    > other words, data can transfer back and forth in page1.html and
    > page2.html.
    >
    > I already wrote the html pages as shown below. However, after clicking
    > the button in page1.html, the data can be shown in text box in
    > page2.html,
    > But when user changes the text box data in page2.html, it will open
    > another window for page1.html, not change the data in existing window
    > for page1.html, and data cannot shown in new window for page1.html
    > also.
    > I am just using regular button, and i am not using submit button.
    >
    > any ideas? Please advise. Thanks!



    You need to keep in mind two things if this is going out onto the internet
    rather than an intranet. A *lot* of people have popup blockers these days,
    so your popup window (via window.open()) will fail. Some people will argue
    you shouldn't use JavaScript at all because people have it disabled, but
    honestly very few people actually disable JS.

    I would probably do much of what's below *server side* and not rely on the
    client misbehaving. Post your data to a server side script instead. You can
    then easily populate form entries in any window you choose.

    <code snipped>
     
    SpaceGirl, Mar 6, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daragoth
    Replies:
    4
    Views:
    614
    Just an Illusion
    Jun 30, 2004
  2. Replies:
    2
    Views:
    490
  3. Abraham Khalil
    Replies:
    1
    Views:
    511
    Knute Johnson
    Jan 26, 2004
  4. umerarain

    Bi directional data signal in cpu

    umerarain, May 18, 2006, in forum: VHDL
    Replies:
    2
    Views:
    634
    umerarain
    May 23, 2006
  5. Matt
    Replies:
    0
    Views:
    237
Loading...

Share This Page