Pretty new to this,
Just trying to get the form input into the generator and out the bottom display. The generator and display are connected just need to get the form input to feed into the generator now
Any help would be appreciated!
</head>
<body>
<div class="background-color">
<h1>Welcome to the Fibonacci Generator!</h1>
<h2>Please input a number between 1 and 10</h2>
<div class="container">
<form class="pure-form">
<input class="numberInputBox" autocomplete="off" id="name"
type="number" placeholder=" Enter # Here!" />
<button type="submit" class="btn btn-success heighttext">GO!
</button>
</form>
<script type="text/javascript">
var nameInput = document.getElementById('name');
document.querySelector('form.pure-
form').addEventListener('submit',
function (e) {
e.preventDefault();
});
</script>
</div>
<div class="display">
<script type="text/javascript">
</script>
<h1>
<script type="text/javascript">
function fibonacciGenerator(n) {
var seq = [0, 1];
for (var i = 2; i < n; i++) {
seq.push(seq.at(-1) + seq.at(-2));
}
seq.length = n;
return seq;
}
document.write(fibonacciGenerator(10));
</script>
</h1>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<footer>
<div class="footer">
</div>
</footer>
Here's a very simple example of passing the result of a fibonacciGenerator function to document.write.
function fibonacciGenerator(n) {
var seq = [0, 1];
for (var i = 2; i < n; i++) {
seq.push(seq.at(-1) + seq.at(-2));
}
seq.length = n;
return seq;
}
document.write(fibonacciGenerator(10));
If you trying to get "result" by using document.getElementById, that doesn't work. getElementById return a tag from the DOM.
You the to attached the var "result" to some tag in you DOM.