dynamically adding options to select tags

Discussion in 'Ruby' started by Josh, Jan 18, 2007.

  1. Josh

    Josh Guest

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

    Thanx for your help!!
    Josh, Jan 18, 2007
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.