Replace the Submit and reset button with a picture

Source: Internet
Author: User
Tags reset

In order to the entire interface beautiful, we need to the submission and reset button to beautify some, but no matter what CSS style definition button, it is difficult to achieve satisfactory results, had to use js+ pictures of the way to deal with, below I was summed up three ways:

1, with pictures instead of submit and reset button, to the picture plus the onclick event

<script language="javascript">
function fsubmit(obj){
  obj.submit();
}
function freset(obj){
  obj.reset();
}
</script>
<form id="form1" name="form1" method="post" action="login.asp">
姓名: <input type="text" name="textfield" />


</form>

2, to 1 of the picture plus style, used to make up for the method 1 mouse moved to the picture no response, failed to give customers a good browsing experience

<script language="javascript">
function fsubmit(obj){
  obj.submit();
}
function freset(obj){
  obj.reset();
}
</script>
<form id="form1" name="form1" method="post" action="login.asp">
姓名: <input type="text" name="textfield" />


</form>

3, with pictures instead of submit and reset button, and add links, the effect of 2

<script language="javascript">
function fsubmit(obj){
  obj.submit();
}
function freset(obj){
  obj.reset();
}
</script>
<form id="form1" name="form1" method="post" action="login.asp">
姓名: <input type="text" name="textfield" />
<a href="javascript:fsubmit(document.form1);"></a>
<a href="javascript:freset(document.form1);"></a>
</form>

4, the use of image fields. Because the default image fields are submitted by clicking on the form, the appropriate processing is done:

<script language="javascript">
function fsubmit(obj){
  obj.submit();
}
function freset(obj){
  obj.reset();
}
</script>
<form id="form1" name="form1" method="post" action="login.asp">
姓名: <input type="text" name="textfield" />
<input type="image" name="imageField" onClick="javascript:fsubmit(document.form1);return false;" src="uploads/200707/30_145425_001.jpg">
<input type="image" name="imageField2" onClick="javascript:freset(document.form1);return false;" src="uploads/200707/30_145428_002.jpg">
</form>

Note that the form submission and reset events in JS must be added (), such as Submit () and reset ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.