So I have this javascript variable I'm generating on my html.erb
views that I want to send to a rails variable the form submit. I understand that I can do this using jquery or ajax but my attempts have failed. Here is what I am trying:
Rails variable:
<%= f.text_field :antennatime, :id => "antenna_time" %>
Some HTML:
<input type="checkbox" id="Antenna" onclick="fun();" value="1">
My javascript:
<script> var str = "This is Some Sample Text"; var ant = document.getElementById("Antenna").checked; if(antenna == true){ $(document).ready(function(){ $("antenna_time").val(str); }); } </script>
To my expectations this is not working. Could someone show the steps I should use to use jquery or ajax to send my javascript var str
to my rails variable :antennatime
?