I am working on a very simple JavaScript FizzBuzz app using Rails, but I can't seem to get the form and its buttons working. I know that this is very rough code, and some of it is in HTML and JavaScript as opposed to Ruby, because I am more familiar with the former two than the latter.
Here is my form:
<p>In this field, put the starting number. It must be a positive integer <50.</p>
<form name="FizzBuzz Form">
<input type="text" name="fizzBuzzStart"/>
</form>
<div class="button" id="start">Add!</div><br>
<p>In this field, put the ending number. It must be a positive integer >50.</p>
<form name="FizzBuzz Form">
<input type="text" name="fizzBuzzEnd"/>
</form>
<div class="button" id="end">Add!</div><br><br>
<div class="button" id="play">Let's play!</div><br>
This is my script.js file:
$("#start").click(function(){
var start = $("input[name=fizzBuzzStart]").val();});
$("#end").click(function(){
var end = $("input[name=fizzBuzzStart]").val();});
$("#play").click(function(){
for (var i=start; i<=end; i++) {
if (i%15===0){console.log("FizzBuzz");}
else if (i%3===0){console.log("Fizz");}
else if (i%5===0){console.log("Buzz");}
else {console.log(i);} }});});
Any advice would be greatly appreciated!