# Dynamic Drop Down Submit problem

**URL:** <https://www.ruby-forum.com/t/dynamic-drop-down-submit-problem/155868>\
**Category:** Rails\
**Created:** [December 17, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/dynamic-drop-down-submit-problem/155868 "2008-12-17T19:57:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![junsha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@junsha](https://www.ruby-forum.com/u/junsha)\
**Post date:** [December 17, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/dynamic-drop-down-submit-problem/155868/1 "2008-12-17T19:57:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![junsha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e19b73/32.png) [@junsha](https://www.ruby-forum.com/u/junsha)\
**Post date:** [December 18, 2008, 2:41am UTC](https://www.ruby-forum.com/t/dynamic-drop-down-submit-problem/155868/2 "2008-12-18T02:41:21Z")

</div>

any1 got clue here?
