Dynamic Drop Down Submit problem


#1

Hi all,

I have a little bit problem with my code here.
basically, i want to have a drop down list, and if i select one value
of the drop down list,
the value of the text field that i have will change its value.

what i have done is to use observe field to dynamically update my text
field.
however, when i am pressing the submit button, it doesnt want to read
the value of the text field.
anyone knows what happen?

here is my code:

chapter controllers:
def upload
@chapter = Chapter.new
@uploads = Book.find(:all)

def get_chapter_number
@books= Book.find(:first,
:conditions => [“title = ?”, params[“title”]])
render :layout => false
end
end

views for upload:
<%= javascript_include_tag “prototype” %>
<% form_for (:chapter, @chapter, :url=>{:action =>
“uploadFile”}, :html => {:multipart => true}) do |f| -%>

        <label class="required">series title:</label>
        <select name="upload[title]" id="upload[title]">
        <% @uploads.each do |upload| %>
          <option value="<%= upload.title %>">
            <%= upload.title %>
          </option>
        <% end %>
        </select>

        <label class="required"> chapter: </label>
        <div id="chapter_container">
        </div>

        <%= observe_field("upload

[title]", :update=>“chapter_container”, :url=>{:action =>
“get_chapter_number”}, :with => ‘title’, :on=>“changed”) %>

         <%= submit_tag 'Upload', :class => "submit" %>

views for get_chapter_number:
<input type=“text” id=“upload_number_of_chapters” name=“upload
[number_of_chapters]” value= <%= @books.number_of_chapters + 1 %> size
= “30” />

that code works fine… if i select the value of the drop down list, it
will dynamically update the text field.
however, when i press the submit button, it doesnt read the value of
the text field that being updated.
any suggestion or help?

thanks in advance,

prawira


#2

any1 got clue here?