1. HTML Object Model
GET or SET:
document.formname.elementname.value
GET e.g., whatisID = document.form1.studentID.value; or SET e.g., document.form1.studentID.value = '1234567';
or
document.forms[ i ].elementname.valueGET e.g., whatisID = document.forms[0].studentID.value; or SET e.g., document.forms[0].studentID.value = '1234567';
or
document.formname.elements[ j ].valueGET e.g., whatisID = document.form1.elements[14].value; or SET e.g., document.form1.elements[14].value = '1234567';
or
document.forms[ i ].elements[ j ].valueGET e.g., whatisID = document.forms[0].elements[14].value; or SET e.g., document.forms[0].elements[14].value = '1234567';
|
 |
2. XML Object Model
GET or SET:
For IE browser: root.childNodes[ i ].childNodes[ j ].textGET e.g., whatisID = root.childNodes[student_num].childNodes[ 1 ].text; or SET e.g.,root.childNodes[student_num].childNodes[ 1 ].text = '1234567';
or
For all browsers: root.childNodes[ i ].childNodes[ j ].childNodes[ 0 ].nodeValueGET e.g., whatisID = root.childNodes[student_num].childNodes[ 1 ].childNodes[0].nodeValue; or SET e.g., root.childNodes[student_num].childNodes[ 1 ].childNodes[0].nodeValue = '1234567';
|
 |
3. Document Object Model
GET or SET:
the object's value: some_id_string.innerHTMLGET e.g., essay = studentEssayTextarea.innerHTML; or SET e.g., studentEssayTextarea.innerHTML = "Type your essay here";
or
the object's value: document.getElementById("some_id_string").innerHTMLGET e.g., essay = document.getElementById('essay').innerHTML; or SET e.g., document.getElementById('essay').innerHTML = "Type your essay here";
GET or SET:
the object's CSS style property: some_id_string.style.css_propertyGET e.g., topColor = topTitle.style.color; or SET e.g., topTitle.style.color = "DarkRed";
or
the object's CSS style property: document.getElementById( "some_id_string").style.css propertyGET e.g., topColor = document.getElementById("topTitle").style.color; or SET e.g., document.getElementById("topTitle").style.color = "DarkRed";
|
 |