I have prototype 1.5 and I can't get the "next" function to work:
Event.observe('sameAsBefore', 'click', function(item){
checkbox = Event.element(item);
if (checkbox.checked == true) {
checkbox.next('address1').value = $('hidden_address1').value;
}
}
Together with the following html:
<div class="some_div">
<a class="sameAsBefore">Same</a>
<input class="address1" name="parent[address1]" size="30" type="text" />
</div>
<div class="some_div">
<a class="sameAsBefore">Same</a>
<input class="address1" name="parent2[address1]" size="30" type="text" />
</div>
I want to trigger the update in the field in the same div, that is why I am using .next().
ERROR:
checkbox.next("address1") is undefined
anonymous(click clientX=645, clientY=300)applicat...259176252 (line 32)
[Break on this error] checkbox.next('address1').value = $('hidden_address1').value;\n
What might be wrong?