SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: forms script

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    forms script

    i want a script to do the following . the form will have three text boxes.

    text box C has something that I have written in it eg "the cat"

    Text box A is empty and the user enters whatever text they want eg "jumps high"

    Text box B I want to work by script. every time A is updated then text box B will contain the text of boxes A and C

    Can anyone do that? It has a practical application.

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    That's pretty basic JavaScript actually. Moving to the JavaScript forum.

  3. #3
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <input /><input onkeyup="this.nextSibling.value=this.value+this.previousSibling.value" /><input />
    Basic but it works. Don't put any line breaks between them or it won't work.

  4. #4
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML Code:
    <input type="text" id="a" />
    <input type="text" id="b" />
    <input type="text" id="c" />
    <script>
    (function() {
      var a = document.getElementById("a");
      var b = document.getElementById("b");
      var c = document.getElementById("c");
      var handler = function() {
        c.value = a.value + b.value;
      }
      b.onkeyup = handler;
      b.onchange = handler;
    })();
    </script>


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
  •