I have a form with, among other things, 2 select boxes. The first
select box determines the content of the second. I have ajax working
fine in dynamically creating the content for the second drop box...
but, unfortunately, the value of that select box never makes it to
@params.
Relevant Code:
#- This simply watches the author select box
<%= observe_field( "author_select", { :update =>
"book_select",
:frequency => 1, :url => { :action => "book_select" }, :with
=>
"''id='' + escape(value)" } ) %>
# The select box for the books, by default it is disabled because the
user must first choose an author
Book:<BR>
<div id="book_select" name="book_select">
<select disabled NAME="review[book_id]" size=1>
<OPTION SELECTED value="-1"> You Must Choose an
Author First
</select>
</div>
# And the contents of the action ''book_select'', which
generates the
content for the Ajaxed observer...
<SELECT name="review[book_id]">
<OPTION SELECTED value="-1"> Choose a Book
<% for book in @books %>
<OPTION value="<%= book.id %>"> <%= book.title
%>
<% end %>
</SELECT>
As above, everything works expect
@params["review"]["book_id"] does
not exist. In order to get *any* book_id value to show up in @params,
I have to completely remove the observer.
Another strange thing... if I move my select tag such that it looks like:
Book:<BR>
<select disabled NAME="review[book_id]" size=1>
<div id="book_select" name="book_select">
<OPTION SELECTED value="-1"> You Must Choose an
Author First
</div>
</select>
(and also remove teh select tag from my ajaxed rendered action), then
I get a javascript error from the observer, stating that "Error: This
container has no properties" (prototype line 245) which really
confuses me because I just moved the select tag, the div, which is
what the observer is designed to change, remained the same.
Anyone have any idea what is going on? Why does the ajaxed form field
not post? Why do I get a JS error by simply moving the select tag
outside the div?
Matt