Reputation: 13378
I have a select list with several options. I wanna choose one then it straight away direct me to a page. I don't wanna have any submit button. How do I do that in Rails?
Upvotes: 1
Views: 2757
Reputation: 7899
You can achieve this with javascript. If you are using jQuery you can do something like this.
$(function(){
$("select#your_select_field_id").change(function(){
if ($(this).val() == "the desired field") {
window.location.href = "http://stackoverflow.com";
}
}
});
I didn't tested the code, it could contain syntax errors, but you can get the idea form this snippet.
Upvotes: 4