My submit button isn't working properly. If someone could look at my code and figure this out it would be great.
Working on an assignment and I need help with 3-4 in my book.
My code is below I need to know what I need to change to make this work properly.
In the browser I need to type in the text box and make it show up on the list on the right, after 5 items have been inputted with the submit button. It needs to display the text "Thank you for your suggestions."
My submit button isn't working properly. If someone could look at my code and figure this out it would be great.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Hands-on Project 3-4</title>
<link rel="stylesheet" href="styles.css" />
<script src="modernizr.custom.05819.js"></script>
</head>
<body>
<header>
<h1>
Hands-on Project 3-4
</h1>
</header>
<article>
<div id="results">
<ul>
<li id="item1"></li>
<li id="item2"></li>
<li id="item3"></li>
<li id="item4"></li>
<li id="item5"></li>
</ul>
<p id="resultsExpl"></p>
</div>
<form>
<fieldset>
<label for="toolBox" id="placeLabel">
Type the name of a tool, then click Submit:
</label>
<input type="text" id="toolBox" />
</fieldset>
<fieldset>
<button type="button" id="button">Submit</button>
</fieldset>
</form>
</article>
<script>
var i = 1;
var listItem = " ";
function processInput() {
if(i<=5) {
listItem = "item"+i;
document.getElementById(listItem).innerHTML=document.getElementById("toolBox");
document.getElementById("toolBox").value=" ";
else(i===5){
document.getElementById("resultsExp1").innerHTML="Thank you for your suggestions.";
}
i++;
}
}
var submitButton = document.getElementById("button");
if (submitButton.addEventListener) {
submitButton.addEventListener ("click", submitForm,false);
else if (submitButton.attachEvent) {
submitButton.attachEvent("onclick", submitForm);
}
}
</script>
</body>
Trending now
This is a popular solution!
Step by step
Solved in 2 steps