I am fooling around with this function that says if you leave this text box blank than print the error code. if its not blank that print one of the text strings. The error code is working but I cannot get it to print any of the text strings. I think the problem is somewhere in returning the random selection to the html doc, I am not sure how to syntax this. When you click the button it executes the function
function button() {
var a = "Punf";
var b = "Relcken";
var c = "Checks in the mail";
var d = "Thae said";
var e = "Drorself";
var f = "Thertions";
var g = "Don stupid";
var err = "You think you are smarter than this website? Your not!"
if (document.getElementById('ask').value == "") {
document.getElementById('answer').innerHTML = err;
}
if (document.getElementById('ask').value == !"") {
var qoute = (a, b, c, d, e, f, g);
var maxQuote = quote.length;
var randQuote = Math.floor(Math.random() * maxQuote);
return quote(randQuote);
document.getElementById('answer').innerHTML = a;
}
}
I have got it down to here but I am still having issues and I am not sure why, Thanks for pointing out my rookie mistakes I need to take a step back and look at it with fresh eyes more.
if (document.getElementById('ask').value == ""){
document.getElementById('answer').innerHTML = err;
}
var quote = [a,b,c,d,e,f,g];
var maxQuote = quote.length;
var randQuote = Math.floor(Math.random()*maxQuote);
document.getElementById('answer').value = quote[randQuote];
}
quoteandqoute...button()function not always return value. Anything else?