iLTC Home
Bookmark iLTC!

Categories

Perl
  • Perl Tutorials Beginners

  • Javascript
  • Javascript Tutorials
  • Javascript Tutorials Beginners

  • HTML
  • HTML Tutorials

  • Command Line
  • Command Line Tutorials

  • How Tos
  • Other Tips and Tricks



  • I love the code... dot com
    2210888

    iLoveTheCode.com

    Mimic Typing from a Textfield in a Textarea with Javascript

    To mimic typing from a textfield in a textarea using Javascript:

    <form name=fo>

    <input type=text name=fi onKeyUp="fo.se.value=fo.fi.value">

    <textarea name=se></textarea>

    </form>


    -We create a form and name it fo because we like short form names.
    -We name our text field fi because we are lazy typers.
    -We name our textarea se because we can.
    -In our textfield fi, we use Javascript's built-in onKeyUp method to work the magic...
    ---We say fo.se.value=fo.fi.value which simply means: make the value of our textarea the same as the textfield.

    fo.se.value
    fo.fi.value
    ---the first section needs the form name which we named fo
    ---the second section needs the form element name which we named se (textarea) and fi (textfield)
    ---the third section is the word value which means we are about to say what we want fo.se equal to. In this instance, we want it to equal the value of fo.fi

    fo.se.value=fo.fi.value


    We could have also made the same thing happen by calling a function of our own making:

    function cHappy() {
    fo.se.value=fo.fi.value;
    }

    <form name=fo>
    <input type=text name=fi onKeyUp="cHappy()">
    <textarea name=se></textarea>
    </form>


    -We just created and named a function cHappy.
    -Put our mimicking code in that function - fo.se.value=fo.fi.value
    -Then called our cHappy function using Javascript's built-in onKeyUp event handler.



    Free Copy and Paste Javascript Code:

    <script type="text/javascript">
    <!--

    function cHappy() {
    fo2.se2.value=fo2.fi2.value;
    }
    -->
    </script>

    <form name=fo2>
    <input type=text name=fi2 onKeyUp="cHappy()">
    <textarea name=se2></textarea>
    </form>

    <br><br>

    <form name=fo>
    <input type=text name=fi onKeyUp="fo.se.value=fo.fi.value">
    <textarea name=se></textarea>
    </form>



    Resources:
    Change a Form Field with Javascript
    Create a Function in Javascript
    Call your Function in Javascript





    Previous Article: Get String Length with Javascript
    Next Article: Close Window with window.close in Javascript






    Search iLTC w/ Google




    Recent Articles

  • HTML Font Code
  • Javascript and CSS - Easy Pop Up Help Balloons
  • Use OnMouseOver in Javascript
  • Use onMouseOut in Javascript
  • Use innerHTML to Change Text on a Page
  • Renaming a File with Perl's RENAME Function
  • PRINT to Browser with document.write Command in Javascript
  • Passing an Argument or Variable to a Javascript
  • Opening an Alert Box in Javascript
  • Opening a REMOTE WINDOW in Javascript
  • OPEN and WRITE a Data File in Perl
  • OPEN and READ a Data File in Perl
  • Mimic Typing from a Textfield in a Textarea with Javascript
  • Javascript Reset Form








  • Perl Programming - Javascript Programming - HTML Code - Mac Unix Command Line - Maybe Some PHP - Free Scripts - ILoveTheCode
    All Content © 2006-2009 iLoveTheCode.com


    Contact Chris | About this Site


    2210099
    Counter by iLoveTheCode.com


    Last Modified: Monday, 09-Feb-2009 02:08:47 EST



    Hosted as well :)
    Home-brewed logo - 1997