Get HTML5 range value in Ruby on Rails form

I am trying to change the standard Ruby on Rails form so that the user enters a value with an HTML5 range. I cannot figure out how to replace the standard "<% = f.text_field: W1%>".

I have a slider:

<input class="slide" type="range" min="0" max="200" id="slider1"> 

Value display in:

 <text id="W1">100</text> 

Thanks Ajax:

  $("#slider1").change(function () { var newValue = $('#slider1').val(); $("#W1").html(newValue); }); 

I can’t find out where and how should I get the input value to install W1?

EDIT: HTML5 range is a rangeyfield formula in Ruby. I'm still looking for the correct implementation, so any help would be appreciated

+6
source share
2 answers

I have it! I had to replace

 <input class="slide" type="range" min="0" max="200" id="slider1"> 

 <%= f.range_field :w1, :min=>0, :max=>200, :class=>"slide", :id=>"slider1"%> 

Thanks to those who helped me!

+12
source
 $("#W1").val(newValue); 

That should do it.

0
source

All Articles