Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 8th, 2003, 10:13 AM
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default submit image button without javascript

I found something on this in the archive which is inconclusive. Within an html page I want to use an image as a submit button but cannot use javascript. What's the best way - Is it possible?

 
Old September 8th, 2003, 10:19 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Yes, you can do that, and it's pretty easy too:
Code:
<input type="image" src="YourImage.gif">
This will add the image to the page as a normal image. However, the image will behave as a button with its type set to "submit".

Unfortunately, there is no way to simulate the Reset button. So, if you need reset functionality, you need JavaScript.

HtH,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 8th, 2003, 10:24 AM
Authorized User
 
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This does that:

http://msdn.microsoft.com/workshop/a...nput_reset.asp

/Robert
 
Old September 8th, 2003, 10:24 AM
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

would I not need to associate it in some way to the form, as in the 'onClick="MyFormName.submit()"' command?

 
Old September 8th, 2003, 10:30 AM
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If I use type="submit" instead of type="image",I'll get the nasy grey button again which is the whole point

 
Old September 8th, 2003, 10:38 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, I know. That's why I explained how to use input tye="image" instead. That will show an image, but behave as an input type="submit" button.

I also think that the link Robert posted, would still use an HTML button for the reset functionality. If you need reset, then add an image and attach some JavaScript to it (or am I missing something here??)

There is no need to associate the input type="image" explicitly with the form, as long as it is inside the <form> tags, just like an ordinary submit button.

Cheers,

Imar



Quote:
quote:Originally posted by vixy
 If I use type="submit" instead of type="image",I'll get the nasy grey button again which is the whole point
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old September 8th, 2003, 10:47 AM
Authorized User
 
Join Date: Jun 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're correct, Imar, I was too fast to answer... :-)

/Robert
 
Old September 8th, 2003, 11:07 AM
Registered User
 
Join Date: Sep 2003
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll give it a go. Thanks a lot. (I'm a graphic designer, not developer so it's all an uphill struggle!)






Similar Threads
Thread Thread Starter Forum Replies Last Post
submit form using javascript with html:button 752004 Struts 2 November 23rd, 2006 12:39 AM
Make a image button as default submit button toshi ASP.NET 1.0 and 1.1 Basics 1 June 1st, 2006 05:25 AM
submit-button grstad Javascript How-To 1 May 25th, 2005 08:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.