#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    328
    Rep Power
    14

    JavaScript rollover w/ <input type="image" ...>


    Hello,

    My JavaScript rollover isn't working properly, could somebody please inform me on what the heck i'm doing wrong

    <div class="menu">&nbsp;</div>
    <div class="content">
    <script type="text/javascript">
    function image_roll(img_swap, img_name)
    {
    document.images[img_name].src = img_swap
    }
    //-->
    </script>

    <div id="border" style="border: 2px solid;"><br /> <form id="update" action="/cms/cat_admin.php" method="post">


    <div style="float: left;">

    <input type="hidden" name="cat_id" value="20">
    &nbsp;
    <div style="margin: 5px 15px; float: left">
    <input type="image" name="save" src="images/save.gif" onmouseover="image_roll('images/savemo.gif', 'save');" />
    </div>
  2. #2
  3. Gogga
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    198
    Rep Power
    22
    Remember to give your image an id as well as a name. Then instead of sending through the name, you send through "this"
    e.g.
    Code:
    <input type="image" id='save' name="save" src="images/save.gif" onmouseover="image_roll('images/savemo.gif', this);" />
    Then in your function, you can just say:
    Code:
    img_name.src = img_swap
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    328
    Rep Power
    14
    Thank you, it's working

IMN logo majestic logo threadwatch logo seochat tools logo