www.fromthevalley.com.au

Setting XHTML element using objects

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 syntax:

oFormObject.elements["element_name"].value = 'Some Value';

If we are accessing the form object through any of the form's elements itself, we can also use the following syntax:

this.form.elements["element_name"].value = 'Some Value';

Let us look at a simple form to clarify the concepts presented so far.

<form name="register_complaint" action="#">

Full Name: <input type="text" size="30" maxlength="155" name="name" >
Email Id: <input type="text" size="30" maxlength="155" name="email" >
Service Complaint: <textarea name="service_complaint" rows="7" cols="50"></textarea>
<input type="button" name="submit" value="Submit Complaint" onclick="showElements(this.form);" >

</form>
HOMEAJAXAPACHEBizphoneCSSDNSGeneralGraphicsHTMLHardwareJavascriptLinuxMACMS SQLMailMicrosoftOFFICE 365PerlPostgresSEOSocial MediaVMwareWindows 10