473,547 Members | 2,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8285
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.tu t.fi> wrote in message
news:xS******** *********@reade r1.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="ja vascript:this.s rc='2.jpg';" onmouseout="jav ascript:this.sr c='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.tu t.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 "economical ly 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="theServ erSideScriptLoc ation">
<!-- The rest of the form stuff -->
<a class="addToCar t" href="javascrip t:document.MyFo rm.submit();">A dd 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:hov er {background: url('addHover.g if')}

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**********@N OSPAMbytronic.c om> 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="addToCar t"
href="javascrip t:document.MyFo rm.submit();">A dd 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.tu t.fi> wrote in message
news:wt******** ******@reader1. news.jippii.net ...
Martin Eyles <ma**********@N OSPAMbytronic.c om> 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="addToCar t"
href="javascrip t:document.MyFo rm.submit();">A dd 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
1562
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 trying to do image swapping This snippet will prevent 'null' from appearing initially and successfully records user changes (typing in a comment)
1
1821
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 another behavior (drop down menu). The former seems pretty easy -- just assign the handler for the onClick event to the swapping function. The...
2
4476
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 want it to swap to "image3" and the next time to "image4" and so on. I´m not so good at javascripts but I found a script that can make the button swap...
3
2283
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 links? I am sure I saw one about 3 years ago. Consider this: A table with a form around it. Each row of the table is numbered 1 to 20. There will...
1
6116
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 pressed. To do this I set the type to hidden and changed the type of the button using javascipt to image. This works perfectly in Modilla's Firefox but...
2
1974
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 file. There are two webpages that use onSubmit event handler to fire a script in an external file but the event handler is no longer firing. onSubmit...
3
5658
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 few buttons. I'm creating interfaces now with many more buttons than "just a few". I solved the maintenance problem by having generic button...
4
11501
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 middle) Of course I like it to be restored if hte user select another color. I've tried to add behaviour to the image (swap on click) and on the...
2
8785
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 then restore when rolled out on a web page in vb.net. please can someone help?
0
7510
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7437
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7463
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7797
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6032
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5081
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3473
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1923
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1050
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.