SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jul 2004
    Location
    charleston
    Posts
    351
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mouseover for submit button in form

    hey all,

    I dont know much about javascript but I am trying to get a little mouseover for a submit button to work.

    <input name="Submit" type="image" id="submit" src="images/button-send.gif" alt="Send Email" />
    <a href="#" onMouseOver="document.Submit.src='images/button-send-over.gif';" onMouseOut="document.Submit.src='images/button-send.gif';"></a>

    am I even close?
    thanks,
    florian

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2007
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's best to use the W3C standard for accessing elements by Id.

    Try:

    Code HTML4Strict:
    <input name="Submit" type="image" id="submit" src="images/button-send.gif" alt="Send Email" />
    <a href="#" onMouseOver="document.getElementById('submit').src='images/button-send-over.gif';" onMouseOut="document.getElementById('submit').src='images/button-send.gif';"></a>

    Note, however that in XHTML, if you are aiming for compliance, "id" is not a valid attribute in input elements, so you will want to use
    Code JavaScript:
    document.getElementsByName('Submit')[0]
    (for the first element with that name) in place of
    Code JavaScript:
    document.getElementById('submit')


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
  •