javascript rollover with a submit button

O

Oxnard

Here's the script section:
function change(color){
var el=event.srcElement
if (el.tagName=="INPUT"&&el.type=="button")
event.srcElement.style.backgroundColor=color
}

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

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

form onMouseover="change('87cefa')" onMouseout="change('d3d3d3')"
input type="button" value="Hosting " class="color2"
onClick="jumpto2('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="processLogin.jsp" method="post" onMouseover="change('87cefa')"
onMouseout="change('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
 
L

Lasse Reichstein Nielsen

Oxnard said:
Here's the script section:

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.srcElement;
if (elem.tagName == "INPUT" && elem.type == "button") {
elem.style.backgroundColor = color;
}
}
---
if the form uses a type=button when kyou rollover the button it changes

form onMouseover="change('87cefa')" onMouseout="change('d3d3d3')"
input type="button" value="Hosting " class="color2"
onClick="jumpto2('hosting.html')"

There is some markup missing here (no said:
however if the input type is submit instead of button when the button is
rolled over it does not change color

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

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.srcElement;
if (elem.tagName == "INPUT" &&
( elem.type == "button" ||
elem.type == "submit" ||
elem.type == "reset")) {
elem.style.backgroundColor = color;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top