Basically, I'm using bootstrap as my CSS, but I'm running into a problem. When I click the button (id="myQuestionButton"), I want it to take the input from the input box (id="myInput") and run it through function checkQuestionWords().
Here's the block of code pertaining to the input and button:
<div class="input-append span9 offset3">
<form>
<input class="span4" type="text" id="myInput"
placeholder="Enter your question."></input>
<button class="btn" type="submit" id="myQuestionButton">
Let's check second.</button>
</form>
</div>
Here's where it will print the preliminary results (for now just in a <div> </div>):
<div id="results"></div>
And here's my function so far:
function checkQuestionWords(){
var theInput = document.getByElementId("myInput");
var theQuestion = theInput.trim();
var questionWords = ["who", "what", "where", "when", "why", "how"];
var isItGood = false;
for (var i=0, i<7; i++){
var holder1 = questionWords[i];
var holder2 = holder1.length;
if (theQuestion.substr(0,holder2) == questionWords[i]){
isItGood = true;
break;}
else{
isItGood = false;}}
if (isItGood == false){
document.getByElementId("results") = "Please enter a question...";}
//the above just reminds them to begin with a question word; see questionWords
else{
document.getByElementId("results") = "all is good";}
}
I tried doing a whole onclick=checkQuestionWords()" inside of the <button ...></button> but that didn't work for some reason.