Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using images for form buttons

Status
Not open for further replies.

peter11

Instructor
Mar 16, 2001
334
US
I am have the following code to use an image as a form button but I need to use the "value" attribute.
Ie. <input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Create Excel&quot;>. The action page uses the &quot;value&quot; attribute to decide what functions to perform.

Also how would I use an image as a clear button?

<A onclick=&quot;document.forms[0].submit();return false&quot; href=&quot;javascript:;&quot;><IMG height=20 alt=&quot;Update Status&quot; src=&quot;../images/buttons/clear.gif&quot; width=52 border=0></A>
 
peter,

You could use a few tricks to make your code more elegant.

First the image input type is a submit button. If you want to use it to do something with your code you can but so it doesn't submit anything make sure you return false in the onclick statement.

In the onclick event handler you can use this.attributeName to have access to information inside any of the attributes.

Try this next example :

<input type=&quot;image&quot; src=&quot;bla.gif&quot; height=&quot;20&quot; width=&quot;45&quot; value=&quot;whatever you like&quot; onclick=&quot;alert(this.value); return false&quot;>

And to reset a form all you have to do is use document.formName.reset() I hope this helps you out! :) Gary Haran
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top