SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast mitsy's Avatar
    Join Date
    Jul 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    making an input box to listen another. need help..

    hello,
    i need to build 2 html forms. the first one can be editable, and the second form will listen to first form which will enable it to have the same values for the variables. Here is the example of what i mean:

    <html>
    <head>
    </head>
    <body>
    <script type="text/javascript">
    function ChangeValue(NewValue)
    {
    document.getElementById("variable1").value = NewValue;
    }
    </script>

    <form name="form1" method="post" action="/form1.php">
    <input id="variable1" value="111">
    </form>


    <form name="form2" method="post" action="/form2.php">
    <input id="variable2">
    </form>


    <button onclick="ChangeValue('333');">change value of 1st one</button>

    </body>
    </html>




    in this example, i want the second input box to listen to the first one. when the first one changes, the second one should automatically dedect the change of the first one, and the second one should get the value of the first one.. (so in this example, when the "change value of 1st one" button is clicked, both of input boxes should get the value of 333)

    how can we make it?
    can anybody help me please, i really need this.
    (i want to do this because i need to use 2 web forms which need to have the same variables with the same values but different action urls.)

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2006
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function follow(){
      var loc1 = document.getElementById('txt1').value;
      document.getElementById('txt2').value = loc1;
    }
    </script>
    </head>
    <body>
    <input type='text' id='txt1' onkeyup='follow()'>
    <input type='text' id='txt2'>
    </body>
    </html>

  3. #3
    SitePoint Enthusiast mitsy's Avatar
    Join Date
    Jul 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for answer!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •