FormsI - Retrieve the value of the element (e.g., text...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
ANNOUNCEMENTS No posting of code in the forum Check class announcements daily 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
FORMS Forms means by which information passes from the user to a server For now we will use forms to read values to be processed by our JavaScript programs <form> tag Defines the form It has two attributes action and method action indicates where the form contents will be sent when the form is submitted method defines how the contents will be sent (post/get) <input>tag Appears inside of the <form> tag Defines several input data alternatives The general format is <input type="ALTERNATIVE" /> ALTERNATIVE can be text, password, checkbox, radio, file, submit, button, reset, hidden, others 2
Background image of page 2
FORM DATA ACCESS We can access data in forms by using document.getElementById(“elementId”) ; getElementById returns a reference to an element that we can use to:
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Retrieve the value of the element (e.g., text field in a form) var login = document.getElementById(&quot;loginId&quot;).value; Set the function to call when an element is clicked on (e.g., button) document.getElementById(&quot;processButton&quot;).onclick = functionDoesProcessing; Get/Set Attributes var imageElement = document.getElementById(&quot;myImage&quot;); var imageName = imageElement.getAttribute(&quot;src&quot;); imageElement.setAttribute(&quot;src&quot;, imageFile.jpg); Example: AssociateButtonWithFunction.html, GetValueInTextField.html Example: UpdateValueInTextField.html, GetSetAttribute.html 3 RESET The functionality of the Reset button is already provided by HTML. You don't need to add any JavaScript or define a button You can change the text associated with the Reset button by using the value attribute Example: GetValueInTextField.html 4...
View Full Document

This note was uploaded on 01/12/2012 for the course CMSC 122 taught by Professor Staff during the Fall '08 term at Maryland.

Page1 / 4

FormsI - Retrieve the value of the element (e.g., text...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online