document.getElementById should do if the element you are looking for has
an id attribute. It searches in the complete HTML document however, not
only inside of the div. If you want to search relative to the div
element then you can use the getElementsByTagName method of the div and
of course the properties like firstChild, lastChild and the childNodes
collection.
A form element object has a property named elements in which you will
find form controls like input, textarea, select and button elements so
you can use
document.forms.formName.elements.controlName
Thanks Martin.
I am using this in the context of an asp.net page.
<div style="border:1px solid #000; width:100%; height: 150px;
overflow:auto;" id="divSelectedRecord">
<span style="float:left;width:150px">Vendor</span>
<span id="spVendor" style="float:left;margin-left:90px"></span>
<span style="float:left;width:150px">Sequence Number</span>
<span id="spSeqNum" style="float:left;margin-left:20px"></span>
<br />
</div>
Then in the script:
var v = document.getElementById('<%=spVendor.ClientID%>'); <--- it
complains spVendor does not exist in the current context
v.innerHTML = some_value;