Use an image to replace the form's submit button submit and reset button Reset

Source: Internet
Author: User
  1. 1. Use an image instead of the submit button submit and reset button reset to add an onclick event to the image.
  2. <Script language = "JavaScript">
  3. Function fsubmit (OBJ ){
  4. OBJ. Submit ();
  5. }
  6. Function freset (OBJ ){
  7. OBJ. Reset ();
  8. }
  9. </SCRIPT>
  10. <Form ID = "form1" name = "form1" method = "Post" Action = "login. asp">
  11. Name: <input type = "text" name = "textfield"/>
  12. </Form>
  13. 2. Add a style to the image in step 1 to compensate for the problem. 1. Move the mouse over the image without any response and fail to give the customer a good browsing experience.
  14. <Script language = "JavaScript">
  15. Function fsubmit (OBJ ){
  16. OBJ. Submit ();
  17. }
  18. Function freset (OBJ ){
  19. OBJ. Reset ();
  20. }
  21. </SCRIPT>
  22. <Form ID = "form1" name = "form1" method = "Post" Action = "login. asp">
  23. Name: <input type = "text" name = "textfield"/>
  24. </Form>
  25. 3. Use an image instead of the submit button submit and reset button reset, and add a link. The effect is the same as 2.
  26. <Script language = "JavaScript">
  27. Function fsubmit (OBJ ){
  28. OBJ. Submit ();
  29. }
  30. Function freset (OBJ ){
  31. OBJ. Reset ();
  32. }
  33. </SCRIPT>
  34. <Form ID = "form1" name = "form1" method = "Post" Action = "login. asp">
  35. Name: <input type = "text" name = "textfield"/>
  36. <A href = "javascript: fsubmit (document. form1);"> </a>
  37. <A href = "javascript: freset (document. form1);"> </a>
  38. </Form>
  39. 4. Use the image domain. Because the default image fields are all submitted forms when clicked, appropriate processing is required:
  40. <Script language = "JavaScript">
  41. Function fsubmit (OBJ ){
  42. OBJ. Submit ();
  43. }
  44. Function freset (OBJ ){
  45. OBJ. Reset ();
  46. }
  47. </SCRIPT>
  48. <Form ID = "form1" name = "form1" method = "Post" Action = "login. asp">
  49. Name: <input type = "text" name = "textfield"/>
  50. <Input type = "image" name = "imagefield" onclick = "javascript: fsubmit (document. form1); Return false;" src = "uploads/200707/30 _145425_001.jpg">
  51. <Input type = "image" name = "imagefield2" onclick = "javascript: freset (document. form1); Return false;" src = "uploads/200707/30 _145428_002.jpg">
  52. </Form>
  53. Note that () must be added after the form submission and resetting events in JS, 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.