HighDots Forums  

Image swap on a Form button

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Image swap on a Form button in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
KiwiBrian
 
Posts: n/a

Default Image swap on a Form button - 05-20-2006 , 08:53 PM






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




Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Image swap on a Form button - 05-21-2006 , 05:00 AM






KiwiBrian <briantoz (AT) ihug (DOT) co.nz> scripsit:

Quote:
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.

Quote:
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?



Reply With Quote
  #3  
Old   
KiwiBrian
 
Posts: n/a

Default Re: Image swap on a Form button - 05-21-2006 , 06:57 AM




"Jukka K. Korpela" <jkorpela (AT) cs (DOT) tut.fi> wrote

Quote:
KiwiBrian <briantoz (AT) ihug (DOT) 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




Reply With Quote
  #4  
Old   
HI-Liter
 
Posts: n/a

Default Re: Image swap on a Form button - 05-22-2006 , 12:00 PM




"KiwiBrian" <briantoz (AT) ihug (DOT) co.nz> wrote

Quote:
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.




Reply With Quote
  #5  
Old   
phil-news-nospam@ipal.net
 
Posts: n/a

Default Re: Image swap on a Form button - 05-22-2006 , 12:27 PM



On Sun, 21 May 2006 13:00:21 +0300 Jukka K. Korpela <jkorpela (AT) cs (DOT) tut.fi> wrote:
Quote:
KiwiBrian <briantoz (AT) ihug (DOT) 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).

--
-----------------------------------------------------------------------------
Quote:
Phil Howard KA9WGN | http://linuxhomepage.com/ http://ham.org/ |
(first name) at ipal.net | http://phil.ipal.org/ http://ka9wgn.ham.org/ |
-----------------------------------------------------------------------------


Reply With Quote
  #6  
Old   
Martin Eyles
 
Posts: n/a

Default Re: Image swap on a Form button - 05-25-2006 , 03:37 AM



"KiwiBrian" <briantoz (AT) ihug (DOT) co.nz> wrote

Quote:
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




Reply With Quote
  #7  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Image swap on a Form button - 05-25-2006 , 04:07 AM



Martin Eyles <martin.eyles (AT) NOSPAMbytronic (DOT) com> scripsit:

Quote:
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.)

Quote:
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/



Reply With Quote
  #8  
Old   
Martin Eyles
 
Posts: n/a

Default Re: Image swap on a Form button - 05-25-2006 , 05:10 AM



"Jukka K. Korpela" <jkorpela (AT) cs (DOT) tut.fi> wrote

Quote:
Martin Eyles <martin.eyles (AT) NOSPAMbytronic (DOT) 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




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.