javascript rollover with a submit button

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oxnard

    javascript rollover with a submit button



    Here's the script section:
    function change(color){
    var el=event.srcEle ment
    if (el.tagName=="I NPUT"&&el.type= ="button")
    event.srcElemen t.style.backgro undColor=color
    }

    function jumpto2(url){
    window.location =url
    }

    if the form uses a type=button when kyou rollover the button it changes

    form onMouseover="ch ange('87cefa')" onMouseout="cha nge('d3d3d3')"
    input type="button" value="Hosting " class="color2"
    onClick="jumpto 2('hosting.html ')"

    however if the input type is submit instead of button when the button is
    rolled over it does not change color here is what I mean:

    form action="process Login.jsp" method="post" onMouseover="ch ange('87cefa')"
    onMouseout="cha nge('d3d3d3')"
    input type="text" name="userName"
    INPUT TYPE="submit" value="Login" class="color2"

    My question is if the method is post and the input type is submit anyway to
    make it rollover? if not what would a javascript look like that would use
    the post method?

    Thanks
    Pete


  • Lasse Reichstein Nielsen

    #2
    Re: javascript rollover with a submit button

    "Oxnard" <shankeyp@no-spam.comcast.ne t> writes:
    [color=blue]
    > Here's the script section:[/color]

    The script is IE-only. Not very good for internet use.

    A more compatible version would be:
    ---
    function change(event, color) {
    var elem = event.target || event.srcElemen t;
    if (elem.tagName == "INPUT" && elem.type == "button") {
    elem.style.back groundColor = color;
    }
    }
    ---
    [color=blue]
    > if the form uses a type=button when kyou rollover the button it changes
    >
    > form onMouseover="ch ange('87cefa')" onMouseout="cha nge('d3d3d3')"
    > input type="button" value="Hosting " class="color2"
    > onClick="jumpto 2('hosting.html ')"[/color]

    There is some markup missing here (no "<"'s and ">"'s).[color=blue]
    >
    > however if the input type is submit instead of button when the button is
    > rolled over it does not change color[/color]

    Ofcourse. The script tests for (elem.type=="bu tton"), so it won't
    match an input element with type="submit".
    [color=blue]
    > here is what I mean:[/color]
    ....[color=blue]
    > My question is if the method is post and the input type is submit anyway to
    > make it rollover?[/color]

    The form's method is not relevant. It is the type of the button that
    fails to be "button". If you want the script to also work on submit
    and reset buttons, you can use:
    ---
    function change(event, color) {
    var elem = event.target || event.srcElemen t;
    if (elem.tagName == "INPUT" &&
    ( elem.type == "button" ||
    elem.type == "submit" ||
    elem.type == "reset")) {
    elem.style.back groundColor = color;
    }
    }
    ---

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    Working...