For Loop in javascript not working properly

Depending on the content of the relative index in array includeit, I want to output, using innerHTML, the correct content of array titles and array links.
The script only generates one line. Each selection should generate two lines.
Maybe it is just a typo but I can't see it.
buttontest.txt
maryj152Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sh0eCommented:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>testnt</title>
<!--<script type="text/javascript" src="scripts/extn.js"> -->
<script type="text/javascript">
var titles = new Array (4);
titles[0] = "Publications Plus (ACES & Extension Publications)";
titles[1] = "ITCS Instructional Materials";
titles[2] = "Extension Turfgrass Publications   ";
titles[3] = "Illinois Steward  ";
 
var links = new Array(4);
links[0] = "https://pubsplus.uiuc.edu/";
links[1] = "http://im.itcs.uiuc.edu/";
links[2] = "http://www.turf.uiuc.edu/extension/extension.html";
links[3] = "http://web.extension.uiuc.edu/illinoissteward/";
 
var includeit = new Array(4);
includeit[0] = "yes";
includeit[1] = "yes";
includeit[2] = "no";
includeit[3] = "no";
 
function showpubs(incl)
	{var ncl = incl;
    document.getElementById("pubs").innerHTML="";
	for(i = 0; i< includeit.length; i++)
		{  if(includeit[i] == ncl)
		 {document.getElementById("pubs").innerHTML+="<a href="+links[i]+"><h3 class=blu>"+titles[i]+"</h3></a>"
			}
		}
	}
 
 
</script>
<style type="text/css">
.blu{color:blue;}
</style>
</head>
 
<body>
<div id="pubs">Content for id "pubs" Goes Here
  <input name="button" type="button" onclick="showpubs('yes')" value="yes" /><br />
<br />
<input name="button" type="button" onclick="showpubs('no')" value="no" />
</div>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
OBonioCommented:
In case you can't see your error, you want to use += when appending to innerHTML instead of just assigning the text with =.  = overwrites what is there already.
0
maryj152Author Commented:
Thank you for your prompt response
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.