Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts

    onclick textfield input help

    yo all,

    need some help with javascript .. I have an onclick event, within it I have a line that reads ..

    Code:
    textfield1.value="GO";
    The textfield1 is on the page however when I click to get the onclick event to move, the page errors, it says 'textfield1 is undefined. I'm not a javascript coder, just play around .. do I need to define the textfield somewhere else?

    Any info would be great,

    cheers,
    Sir P

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    <form>
    <input type="text" name="textfield1"><br>
    <input type="button" onclick="this.form.textfield1.value='GO'">
    </form>

  • #3
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    try this:

    <script>
    function MyClickEvent(){

    document.myFormName.MyFieldName.value="GO";

    }
    </script>

    <form name='myFormName'>
    <input type='text' name='MyFieldName' onClick='MyClickEvent();' />
    </form>


  •  

    Posting Permissions

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