472,958 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 8250
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.