Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Submit

Instances are created by the browser when it encounters an HTML tag with the TYPE attribute set to SUBMIT. In the JavaScript object hierarchy, the Submit object is located at window.document.Form.Submit. Event Handlers/Methods/PropertiesDescription onBlurCalled when the submit button loses focus. onClickCalled when the submit button is clicked. onFocusCalled when the submit button receives the focus. blur()Removes focus from the submit button. click()Simulates a mouse click on the submit button. focus()Gives the focus to the submit button. handleEvent()Invokes the handler for the event specified and was added in JavaScript 1.2. formReturns the entire form the submit button is in. nameReturns the name of the submit button specified by the NAME attribute. typeReturns the type of this submit button specified by the TYPE attribute. This property always returns submit. valueReturns the value of this submit button specified by the VALUE attribute. <html>     <head>     <script language="JavaScript">     <!--     function openWin(){       var myInstance = document.myForm.mySubmit;       var myWin = open("", "","width=450,height=200");       myWin.document.write("The name is: " + myInstance.name + "<br>");       myWin.document.write("The type is: " + myInstance.type + "<br>");          myWin.document.write(myInstance.form.mySubmit.value);       myWin.document.close();     }     -->     </script>     </head>     <body>     <form name="myForm">       <input type=TEXT value="Hello, World!" name="myText">     <input type=SUBMIT value="Click to Submit" name="mySubmit"              onClick="openWin()">     </form>     </body>     </html>