jasrasr
06-17-2009, 02:18 PM
I am trying to write a stored value from a for loop to a div. I need to use a div instead of document.write because it needs to go below an existing div.
here's the code:
<code>
<script>
var id21112=['Unregistered','Armani FC','Lots n Lots of Fame','15.2','$$$'];
var id21111=['Matrix','Armani FC','Magnolyah','15.2','$$$'];
var text="";
text += ("<table border=1><tr>");
for (var x=0;x<5;x++) { text += ("<td>"+id21112[x]+"</td>");}
text += ("</tr><tr>");
for (var x=0;x<5;x++) { text += ("<td>"+id21111[x]+"</td>");}
text += ("</tr></table>");
//this works fine.
document.write(text);
//this does nothing
//document.getElementById('horse').innerHTML = text;
</script>
</code>
html code
<code>
<div id=horse></div>
</code>
if you try this make sure you only use one and them comment it out to use the other.
I need to know if there is another way to do this. I am using this in a matrix to sort horses out by gender, breed, age, color. this code will display the horses that fall in to the selected categories.
here's the code:
<code>
<script>
var id21112=['Unregistered','Armani FC','Lots n Lots of Fame','15.2','$$$'];
var id21111=['Matrix','Armani FC','Magnolyah','15.2','$$$'];
var text="";
text += ("<table border=1><tr>");
for (var x=0;x<5;x++) { text += ("<td>"+id21112[x]+"</td>");}
text += ("</tr><tr>");
for (var x=0;x<5;x++) { text += ("<td>"+id21111[x]+"</td>");}
text += ("</tr></table>");
//this works fine.
document.write(text);
//this does nothing
//document.getElementById('horse').innerHTML = text;
</script>
</code>
html code
<code>
<div id=horse></div>
</code>
if you try this make sure you only use one and them comment it out to use the other.
I need to know if there is another way to do this. I am using this in a matrix to sort horses out by gender, breed, age, color. this code will display the horses that fall in to the selected categories.