HOWTO: Submitting a Form From an Anchor (<A HREF=...>).

ID: Q166210


The information in this article applies to:


SUMMARY

This article describes how a form can be submitted to a server through the use of an anchor. It uses the little-known ability of JScript that allows you to run a script from an anchor without using events.


MORE INFORMATION

There are two simple steps to submitting a form from an anchor:

  1. Be sure the form has values for the NAME, ACTION, and METHOD properties. The NAME and ACTION properties are the only required ones, but it is a good idea to supply the METHOD also, for example:
    
          <FORM NAME=Form1 ACTION="http://myServerURL/MyPage.asp" METHOD=POST>
          </FORM> 


  2. Call a one-line script from an anchor. In the script, call the submit method of the form, for example:
    
    <A HREF="JAVASCRIPT:Form1.submit()"> Something </A> 
    NOTE: JavaScript is case-sensitive, so submit must be spelled all lowercase.



REFERENCES

For additional information on JScript and forms visit the MSDN Online Web Workshop:

http://msdn.microsoft.com/workshop/

Additional query words: jscript javascript script


Keywords          : kbJScript100 kbJScript300 kbJScript500 vbObjMdlIE vbObjMdlOther 
Version           : 1.0
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: April 29, 1999