Click to See Complete Forum and Search --> : Using an Image for a button, not submit
rbudj
10-08-2003, 03:26 PM
I need to use an image in place of the standard button type in html. Here is an example code...
<input type="button" value="Master Closet Left" onclick="document.images[0].src='image3.gif'">
The onClick is some simple JavaScript to display my image.
I have tried several things including...
<input type="image" src="..."
but it does not work for the onClick.
Anyone know how I can do this?
rbudj
10-08-2003, 03:29 PM
Ok, sorry, .. I posted this message in the html area and since it actually deals more in detail with JavaScript, I think it should be posted here. Please forgive this time:(
I need to use an image in place of the standard button type in html. Here is an example code...
<input type="button" value="Master Closet Left" onclick="document.images[0].src='image3.gif'">
The onClick is some simple JavaScript to display my image.
I have tried several things including...
<input type="image" src="..."
but it does not work for the onClick.
Anyone know how I can do this?
Charles
10-08-2003, 04:00 PM
You could use the BUTTON (http://www.w3.org/TR/html4/interact/forms.html#edef-BUTTON) element but you'd still have the problem of a page that doesn't work for the 13% of users who do not use JavaScript. Keep using the "image" type of INPUT element but put each one in a separate form thusly..
<form action="image3.gif" onsubmit="document.images[0].src = this.action; return false">
<div>
<input type="image" alt="Master Closet Left" src="image3a.gif">
</div>
</form>
That will give you the result that you are seeking yet still keep things running for those good JavaScript free users. And note, that if this is for a commercial site then you may be required by law to keep things working for those good folks.
Charles
10-08-2003, 04:03 PM
See your other post (http://forums.webdeveloper.com/showthread.php?s=&threadid=18920).
rbudj
10-08-2003, 04:10 PM
Thanks for the reply.. I am working on your examples now.. in the mean time.. can you tell me about your last quote about being for a commercial site required by law to keep things working for those folks. You obviously know something I don't. Can you tell me the details because yes.. this is for a small client of mine.
Thanks a bunch!
Charles
10-08-2003, 04:34 PM
Originally posted by rbudj
Thanks for the reply.. I am working on your examples now.. in the mean time.. can you tell me about your last quote about being for a commercial site required by law to keep things working for those folks. You obviously know something I don't. Can you tell me the details because yes.. this is for a small client of mine.
Thanks a bunch! It all deopends on where you are. The laws in the US are on the lax side but the Americans with Disabilities Act (http://www.usdoj.gov/crt/ada/pubs/ada.txt) requires under Title III that commerial enterprises be accessible to persons with disabilities. And the Department of Justice is of the opinion that this applies to the internet (http://www.usdoj.gov/crt/foia/tal712.txt). Fortunately the W3C has published a wonderful set of Web Content Accessibility Guidelines (http://www.w3.org/TR/WCAG10/).
rbudj
10-08-2003, 04:55 PM
Thank you so very much....
I have played with your code example and it works perfectly!!!
Thank you also for posting about the disability requirements. I have been designing websites for about a year or so and I always give an alt tag to all my images with a good explaination of the image. I will further research how I can make my sites better for the disabled. Thank you , Thank you.
By the way, I am located in the U.S.
I am so happy :-)