I'm using a html-form with nested div-elements with this structure:
<form id="form">
<div id="parentproperties">
<legend class="itemName">People</legend>
<br>
<div id="properties1">
<legend class="itemName">Name</legend>
<label class="valueId">JaneDoe</label>
<br>
<label class="labelId">Id: </label>
<input class="inputId">5646543</input>
</div>
<div id="properties2">
<legend class="itemName">Address</legend>
<label class"valueId">MysteriousStreet</label>
<br>
<label class="labelId">Id: </label>
<input class="inputId">1234</input>
</div>
<div id="properties3">
<legend class="itemName">Country</legend>
<label class"valueId">SomeCountry</label>
<br>
<label class="labelId">Id: </label>
<input class="inputId">7899542</input>
<div id="properties4">
<legend class="itemName"></legend>
<br>
</div>
</div>
</div>
</form>
Now I need to access the field with the Id 'valueID' for every 'div' to change a specific value. I've tried several loops but they do not not work properly... Later I've tried to get a particular element directly this way:
document.getElementById("properties").childNodes[0].innerHTML;
...but I only get the first valueId with value 'JaneDoe'. Thanks in advance for any ideas!
ids are supposed to be unique within the document. Useclassordata-*attribute to group elements.