Here's my html so far:
<html><body><head><script>
Array.prototype.sample = function(){
return this[Math.floor(Math.random()*this.length)];
}
var sentances = ['This new amazing product will be in every home by 2021','Buy this now- before we run out of stock!','Get this now, before everyone else will have one!'].sample()
var quotes = ['“This is amazing!"','"Buy it Now!"'].sample()
var titleback = ['"Nothing can beat','"How can you not love'].sample()
var title = document.getElementById("title")
function myfunction() {
document.getElementById("Sentances").innerHTML = sentances;
document.getElementById("Quotes").innerHTML = quotes;
document.getElementById("Titleback").innerHTML = titleback + title;
}</script></head><h2>Auto Ad Generator</h2><p>Enter the title of your product:</p><form method="post" action="."><p><input name="name" id="title"></p><button type="button" id="button" onclick="myfunction()">Try it</button><p><input name="name2" type="reset"></p></form><p id="Sentances"></p><p id="Sentances2"></p><p id="Quotes"></p><p id="Titleback"></p></body></html>
Though when I run this on the website (sites.google.com/view/generator-ad/home), it just prints the word 'null' next to the sentence randomly chosen from 'titleback'. Why does it do this, and not print the name of the product the user inputted at the start? I'm new to javascript and so sorry if the answer is obvious. Any help would be appreciated.