Dynamically adding options to select tags


The set up is this: Throughout the page I have a certain drop-down
repeated many times. It is given class=“owner_column” It’s possible I
could generate a unique ID for each of these, but it may prove to be
difficult – although I’ll manage if it turns out to be necessary.

My problem is adding a new “owner” to all of these drop downs
dynamically. I’ve been experimenting with variations on the

page.select(‘select.owner_column’).each do |foo|
foo.replace_html ‘blah’

Where “blah” will probably end up being a partial or an explicit
statement. But for the time being even inserting the word
“blah” isn’t working.

This produces an error saying that “replaceHtml” is not a valid
function. Notice that at some point my “replace_html” got changed to
“replaceHtml” (I’m not sure why or how this happened)

Some points to consider:

If instead I do foo.hide all of the select statements disappear as
expected. This leads me to believe my select statement is accurately
grabbing the correct objects.

replace_html takes an id argument. Is it mandatory, if so, what do
send in its placesince I dynamically grabbed the objects I want to

Thanx for your help!!