dynamically adding options to select tags

J

Josh

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
following:

page.select('select.owner_column').each do |foo|
foo.replace_html 'blah'
end

Where "blah" will probably end up being a partial or an explicit
<object> 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
modify?

Thanx for your help!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top