I have a field on a form that is hidden but pulls data from another field to fill it in. Yet when I have tried it it does not work. I need to use class not id to fill the field.
Field with onblur Event
<input name="EmailAddress" type="text" class="cat_textbox" id="EmailAddress"
onblur="document.getElementByClass('Username2').value=this.value;"
maxlength="255" />
Field That Is Being Filled
<input type="text" class="Username2" id="Username" name="Username" />
There is no
.getElementByClass()as far as I know; it’s.getElementsByClassName()(note: element*S* is plural, since it can return more than one). When using it to get one element, you need to add its array index at the end ([0]).Try: