Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2668 > unrolled thread
| Started by | Edgars Liepa <exedzy@gmail.com> |
|---|---|
| First post | 2011-04-12 03:14 -0500 |
| Last post | 2011-04-12 03:14 -0500 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.ruby
fill form when collection_select is changed Edgars Liepa <exedzy@gmail.com> - 2011-04-12 03:14 -0500
| From | Edgars Liepa <exedzy@gmail.com> |
|---|---|
| Date | 2011-04-12 03:14 -0500 |
| Subject | fill 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/.
Back to top | Article view | comp.lang.ruby
csiph-web