Jump to content

Text Looping in Javascript


gardan06

Recommended Posts

I have:

<div id="name"></div>

Given the names "Michael", "Lue" and "Rachel" for example, how can i loop these 3 inside the div given? Is it even possible?

 

In case you guys are wondering, i need it to put names in a table wherein the column has a limited width and height. Needless to say, it should only occupy 1 line, thus this solution.

 

Thanks.

 

Link to comment
https://forums.phpfreaks.com/topic/88530-text-looping-in-javascript/
Share on other sites

 

you mean like this:

 

<div id="name">
<script language="javascript">
var people = new Array();
people[0] = "Michael";
people[1] = "Lue";
people[2] = "Rachel";
var max = people.length - 1;
for (i=0;i<=max;i++)
{
document.write(""+people[i]+"<br/>");
}
</script>
</div>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.