Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #2668 > unrolled thread

fill form when collection_select is changed

Started byEdgars Liepa <exedzy@gmail.com>
First post2011-04-12 03:14 -0500
Last post2011-04-12 03:14 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.ruby


Contents

  fill form when collection_select is changed Edgars Liepa <exedzy@gmail.com> - 2011-04-12 03:14 -0500

#2668 — fill form when collection_select is changed

FromEdgars Liepa <exedzy@gmail.com>
Date2011-04-12 03:14 -0500
Subjectfill form when collection_select is changed
Message-ID<81ba95d8585a1c4f9fc82339c6ea5fe6@ruby-forum.com>
Hey there. :)
I have a problem.
I have collection_select, witch takes values from DB
I need to run fill textboxes from other table in DB, when
collection_select is selected.. can anyone tell me how can i make this
run function when collection_select is changed, cos my code is not
working..
And i have jquery in my ruby on rails project, so thats ok..

my code:

<script type="text/javascript">

        function fill_form(a)
            $.getJSON('/sticks/' + a.id + '.json', function(data) {
              var items = [];

              $.each(data, function(key, val) {
              alert(key + ': ' + val)
              };
            */
            }
          }
        </script>
        <%= f.label :stick_type %>
        <%= h.collection_select :stick_id, Stick.all, :id, :stick_type,
:prompt => "Select Stick", :onchange => "fill_form(this)" %>
        <br />

-- 
Posted via http://www.ruby-forum.com/.

[toc] | [standalone]


Back to top | Article view | comp.lang.ruby


csiph-web