Forum: Ruby on Rails Dynamic Drop Down Submit problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E65ae5a36996457abdf3ca7c377ca69a?d=identicon&s=25 JunSha (Guest)
on 2008-12-17 19:57
(Received via mailing list)
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
E65ae5a36996457abdf3ca7c377ca69a?d=identicon&s=25 JunSha (Guest)
on 2008-12-18 02:41
(Received via mailing list)
any1 got clue here?
This topic is locked and can not be replied to.