<script>
function autofillForm() { document.getElementbyId('add').getElementsByName('foo')[0].value = 'bar'; }
</script>
<form id="add">
Foo<input name="foo" value="" />
</form>
<a onClick="autofillForm()">Click to fill</a>
I’m just trying to get it so that when I run the function, the form fills with “bar”. Where am I going wrong?
hence
EDIT: Of course,
getElementsByName()is only supported on the document object itself, so it must be: