Reputation: 758
I have this code below. I need to use a class id instead of the index to update the item. Say my class name was "initials" How would I use that to update the field instead of an index, just in case someone changed it?
$$('select.employee_select').each( function(elm) {
elm.observe('change', function(ev) {
item = elm.childElements().find(function(ele){return !!ele.selected});
item = item.readAttribute('value');
elm.up().previousSiblings()[3].update(item); *** I want to change this line by class name instead of the index ***
serv_id = elm.up().previousSiblings()[13];
serv_id = serv_id.readAttribute('value');
employee_id = elm.up().previousSiblings()[4];
employee_id = employee_id.readAttribute('value');
Upvotes: 0
Views: 5499
Reputation: 219814
You can refer to it in array notation:
$$('select.employee_select .initials')[0]
or if it is the only element with that class:
$$('.initials')[0]
Upvotes: 3