E
Edgars Liepa
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,
rompt => "Select Stick", nchange => "fill_form(this)" %>
<br />
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,
rompt => "Select Stick", nchange => "fill_form(this)" %>
<br />