Reputation: 11
So im quite new to Ruby. I already have some HTML/HAML experience, now I want to do a simple Website with this: A input field and a submit button.
If the user input is < 10 it should display some picture, if its > 10, it should display a other picture. This is what I've done so far:
What should I do now to proccess the user input ? I just can't figure out.
Upvotes: 0
Views: 377
Reputation: 52
In this case, where you are not doing any server side processing, you should use JavaScript.
Just check value of the input field and do your logic from there.
$('form').on('submit',function(){
if ($('#Input1').val() < 10) {
$("#my_image").attr("src","first.jpg");
}
else {
$("#my_image").attr("src","second.jpg");
}
})
Upvotes: 1
Reputation: 503
Your form syntax is incorrect, it missing the controller action. It should be like this:
= form_for controller_method, :html => { :class => "form-horizontal" }
Upvotes: 0