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


Groups > comp.lang.ruby > #2668

fill form when collection_select is changed

From Edgars Liepa <exedzy@gmail.com>
Newsgroups comp.lang.ruby
Subject fill form when collection_select is changed
Date 2011-04-12 03:14 -0500
Organization Service de news de lacave.net
Message-ID <81ba95d8585a1c4f9fc82339c6ea5fe6@ruby-forum.com> (permalink)

Show all headers | View raw


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/.

Back to comp.lang.ruby | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web