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 4 of 4
  1. #1
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Function and argument - "...." is not an object

    <head>
    <script type="text/javascript">

    function inputOver(fname,field)
    {
    document.fname.field.style.background='#95aabf';
    }
    </script>
    </head>
    <body>
    <form id="form" action="(EmptyReference!)" method="get" name="form">
    <input class="text" type="text" name="text1" size="24" border="0" onmouseover="inputOver('form','text1')" />
    </form>
    </body>
    Last edited by Phip; 10-26-2003 at 01:00 AM.

  • #2
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Simplified it a little ^^

  • #3
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Hello -

    You can use document.getElementById and it seems to work.

    <head>
    <script type="text/javascript">

    function inputOver(fname)
    {
    document.getElementById(fname).style.background='#95aabf';
    }
    </script>
    </head>
    <body>
    <form id="form" action="(EmptyReference!)" method="get" name="form1">
    <input class="text" type="text" id="text1" name="text1" size="24" border="0" onmouseover="inputOver('text1')" />
    </form>
    </body>

    Basscyst
    Helping to build a bigger box. - Adam Matthews

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    <input .... onmouseover="inputOver(this);" ...>
    Code:
    function inputOver(field) {
        field.style.backgroundColor='#95aabf';
    }
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

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