Congratulations - Details Apply
How to set the value of a form element using Javascript Form Handling, Javascript Form Handling javascript form field, javascript form value, javascript set form field, text box As we have seen in earlier articles, in order to work with forms in JavaScript, it is imperative to obtain references to the form object and its elements. In this article, we will be using the forms collection of the document object and the elements collection of the form object to set the values of the form elements. The syntax for accessing the form object is as below: oFormObject = document.forms; For accessing individual elements, we use the following code: oformElement = oFormObject.elements1; OR oFormElement = oFormObject.elements; In the above code, "index" refers to the position of the element in the "elements" collection array, and "element_name" is the name of the element. Both approaches give us a reference to the desired form element. Setting the value of a textarea element using JavaScript In order to set the value of a textarea field element in a form, we can use the following code: oFormObject.elements.value = 'Some Value'; If we are accessing the form object through any of the form's elements itself, we can also use the following code: this.form.elements.value = 'Some Value'; Let us look at a simple form example.
Full Name: Email Id: Service Complaint: