By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,041 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Image swap on a Form button

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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

P: n/a

"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

P: n/a

"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

P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.