473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

javascript rollover with a submit button



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
Jul 23 '05 #1
1 2211
"Oxnard" <sh******@no-spam.comcast.net> writes:
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 "<"'s and ">"'s).
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;
}
}
---

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Frances Del Rio | last post by:
I have a form in which submit button is an img.. would like to do it w/a rollover, but can't get rollover to work.. can you do rollovers w/img submit buttons? this is code I have: <input...
21
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script...
6
by: AJBopp | last post by:
I'm wrestling with CSS variations between Firefox and IE. I'm trying to create rollover buttons in a menu frame. It is working perfectly in Firefox but in IE only the first button is properly...
1
by: Savas Ates | last post by:
How can i add javascript code to my server control object ? I want to add a javascript code when a user OnClick it .. Is there any sample code or reference web site or knowledge to solve it ?...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
5
by: Rabel | last post by:
I am a flash designer so I dont know a whole lot about the javascript submit buttons (I may not even be describing it right sorry) but here is the code I am using. <IMG name="Checkout"...
1
by: willCrain | last post by:
I am pretty much stuck and dont know which direction to procede in figuring this out. My desired end result is to have top_home button and bottom_home button to be on opposite areas of the page, but...
3
by: Oriane | last post by:
Hi there, I would like to handle a "rollover" <asp:Buttonin the code behind with C# with this kind of code: Button btn = Page.FindControl("Button" + numWidget) as Button; btn.Attributes =...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.