473,320 Members | 2,104 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,320 software developers and data experts.

Image swap on a Form button

On a web page I have a graphic for a Shopping Cart Submit button.
It is within a form and working fine.
I would like to perform an image swap to an identical graphic of a
different colour when I hover over the button.
Can anyone show me how to do this, or point me to an implementation.
My present code for the submit button is:-
<input type="image" name="submit" src="images/addtocart1.gif">
This changes the cursor to a hand, and operates the button when clicked.
I just want to add the image swap on hover.
Must work identically on IE6 and Firefox.
I have Googled for hours, and tried many options, all unsuccessfully so far.
TIA for any advice
Brian Tozer

May 21 '06 #1
7 8265
KiwiBrian <br******@ihug.co.nz> scripsit:
On a web page I have a graphic for a Shopping Cart Submit button.
You asked the same question in alt.html. If you want help in this group,
please summarize the answers you got elsewhere and explain why they were not
satisfactory.
<input type="image" name="submit" src="images/addtocart1.gif">


You have a much more serious problem there than the visual rendering problem
that you are now struggling with. What happens on a text-based user agent,
or on a graphic browser with image loading disabled?

May 21 '06 #2

"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:xS*****************@reader1.news.jippii.net.. .
KiwiBrian <br******@ihug.co.nz> scripsit:
On a web page I have a graphic for a Shopping Cart Submit button.


You asked the same question in alt.html. If you want help in this group,
please summarize the answers you got elsewhere and explain why they were
not satisfactory.
<input type="image" name="submit" src="images/addtocart1.gif">


You have a much more serious problem there than the visual rendering
problem that you are now struggling with. What happens on a text-based
user agent, or on a graphic browser with image loading disabled?


Thanks for the comments Jukka.
The page that has the submit buttons which I would like to do the image swap
on hover on is:-
http://www.nzreinol.co.nz/hcr.html
I am hoping that the points that you have raised are not a practical problem
for this client.
Brian Tozer
May 21 '06 #3

"KiwiBrian" <br******@ihug.co.nz> wrote in message news:e4**********@lust.ihug.co.nz...
On a web page I have a graphic for a Shopping Cart Submit button.
It is within a form and working fine.
I would like to perform an image swap to an identical graphic of a
different colour when I hover over the button.
Can anyone show me how to do this, or point me to an implementation.
My present code for the submit button is:-
<input type="image" name="submit" src="images/addtocart1.gif">
This changes the cursor to a hand, and operates the button when clicked.
I just want to add the image swap on hover.
Must work identically on IE6 and Firefox.
I have Googled for hours, and tried many options, all unsuccessfully so far.
TIA for any advice
Brian Tozer


<input type="image" name="submit" src="1.jpg" onmouseover="javascript:this.src='2.jpg';" onmouseout="javascript:this.src='1.jpg';">

Here's a way that works in ie6.
May 22 '06 #4
On Sun, 21 May 2006 13:00:21 +0300 Jukka K. Korpela <jk******@cs.tut.fi> wrote:
| KiwiBrian <br******@ihug.co.nz> scripsit:
|
|> On a web page I have a graphic for a Shopping Cart Submit button.
|
| You asked the same question in alt.html. If you want help in this group,
| please summarize the answers you got elsewhere and explain why they were not
| satisfactory.
|
|> <input type="image" name="submit" src="images/addtocart1.gif">
|
| You have a much more serious problem there than the visual rendering problem
| that you are now struggling with. What happens on a text-based user agent,
| or on a graphic browser with image loading disabled?

Or even on older browsers that lots of people still use, and many must
still use because of their "economically challenged" status (along with
slow access, etc).

--
-----------------------------------------------------------------------------
| Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
| (first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------
May 22 '06 #5
"KiwiBrian" <br******@ihug.co.nz> wrote in message
news:e4**********@lust.ihug.co.nz...
On a web page I have a graphic for a Shopping Cart Submit button.
It is within a form and working fine.
I would like to perform an image swap to an identical graphic of a
different colour when I hover over the button.
Can anyone show me how to do this, or point me to an implementation.
My present code for the submit button is:-
<input type="image" name="submit" src="images/addtocart1.gif">
This changes the cursor to a hand, and operates the button when clicked.
I just want to add the image swap on hover.
Must work identically on IE6 and Firefox.
I have Googled for hours, and tried many options, all unsuccessfully so
far.
TIA for any advice
Brian Tozer


The only way to do this in CSS _AND_ to have it work in IE6 is to replace
your submit buttons with links. Something like:

<form id="MyForm" name="MyForm" method="post"
action="theServerSideScriptLocation">
<!-- The rest of the form stuff -->
<a class="addToCart" href="javascript:document.MyForm.submit();">Add To
Cart</a>
</form>

and then use CSS to style the link. Something like:

a.addToCart {margin-left: -5000px; display: block; width: 150px; height:
50px; background: url('add.gif')}
a.addToCart:hover {background: url('addHover.gif')}

It is rough, but should give some idea. You might want to search for "Image
Replacement" to refine the CSS a bit, and for form, submit and javascript to
refine the HTML.

HTH,
Martin
May 25 '06 #6
Martin Eyles <ma**********@NOSPAMbytronic.com> scripsit:
The only way to do this in CSS _AND_ to have it work in IE6 is to
replace your submit buttons with links.
Why should be done in CSS only? (Assuming you want to do it in the first
place, which is a bad idea.)
<a class="addToCart"
href="javascript:document.MyForm.submit();">Add To Cart</a>


Although you technically play with "CSS only" as far as the image swap is
considered, your approach has made you replace the submit button by a link
that does nothing when JavaScript is off, i.e. the form cannot be submitted
without allowing JavaScript execution. Risking _essential functionality_ to
achieve some visual effect _and_ to achieve it in "CSS only" is absurd in
WWW authoring.

If you don't want to use JavaScript for the image swap while making the
functionality dependent on JavaScript in a more important issue, you should
at least generate the above markup dynamically with JavaScript and insert a
<noscript> element with a normal submit button as its content.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

May 25 '06 #7
"Jukka K. Korpela" <jk******@cs.tut.fi> wrote in message
news:wt**************@reader1.news.jippii.net...
Martin Eyles <ma**********@NOSPAMbytronic.com> scripsit:
The only way to do this in CSS _AND_ to have it work in IE6 is to
replace your submit buttons with links.


Why should be done in CSS only? (Assuming you want to do it in the first
place, which is a bad idea.)
<a class="addToCart"
href="javascript:document.MyForm.submit();">Add To Cart</a>


Although you technically play with "CSS only" as far as the image swap is
considered, your approach has made you replace the submit button by a link
that does nothing when JavaScript is off, i.e. the form cannot be
submitted without allowing JavaScript execution. Risking _essential
functionality_ to achieve some visual effect _and_ to achieve it in "CSS
only" is absurd in WWW authoring.

If you don't want to use JavaScript for the image swap while making the
functionality dependent on JavaScript in a more important issue, you
should at least generate the above markup dynamically with JavaScript and
insert a <noscript> element with a normal submit button as its content.


Good points! Given these, I don't have any decent solutions.

Martin
May 25 '06 #8

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

Similar topics

2
by: uNConVeNtiOnAL | last post by:
Hi - I have a page that has a button that makes a prompt appear for the user to type input. When they have typed in input, I want the button to change color when the prompt closes. I am...
1
by: Weston C | last post by:
I'm working on a small javascript application where I'd like to get one behavior when a user clicks on an image (image swap), but when they simply hold down the mouse button for a second, they get...
2
by: broms10 | last post by:
I need help. I have a little button that says "next" below a big image, let´s call it "image1", when I press the button I want to swap the big image to "image2". And then if I press it again I...
3
by: Dooza | last post by:
Hi there, I was wondering if anyone had come across some javascript that would allow me to have a chart of say 20 music tracks, and be able to move each track up and down the chart using up/down...
1
by: Phil_Cam | last post by:
Hello All On a webpage I have a standard paypal image button for purchases. I am trying to set it up so that it only shows up or is endabled when text is entered into a textbox and a button is...
2
by: Bundy | last post by:
Hi On my webpages I have replaced the submit button with a rolling submit button using the script below (Script 1). This script is used by many of my webpages and is included in a external...
3
by: seamlyne | last post by:
The first method I ever used for multiple state buttons was to create a graphic for each button for each state: AboutUs_on, AbooutUs_over, AboutUs_out, etc. That works great when there are just a...
4
by: lemat | last post by:
Hi, I use a radio button form in which users can select a color by clicking on a image. I would like this image to change to another one when it's chosen. (image with a "Chosen" Stamp in the...
2
by: smokeyd | last post by:
i am trying to create a simple image button rollover.. i have searched this forum and found a number of solutions but none seem to work. i am just trying to get the onmouseover to swap the image...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.