Reputation: 9
My title for this question may not be using the correct terminology but here is what I would like to do. (I am still new to Javascript so im looking for a basic method)
First my table has to be created using Javascript, then I need to take an array object/element and "write" it to a table cell.
I say "write" because I'm not sure if that's the correct word to use.
Here is an example of the code I'm working with:
<script type="text/javascript">
/* <![CDATA[ */
var day = [];
day[0] = "monday"
document.write("<table>")
document.write("<tr><td>"**what syntax do i use to insert the data for "day[0]" here**"</td></tr>")
document.write("</table>")
/* ]]> */
</script>
Upvotes: 0
Views: 240
Reputation: 2154
try
<script type="text/javascript">
/* <![CDATA[ */
var day = [];
day[0] = "monday";
document.write("<table>")
document.write("<tr><td>" + day[0] + "</td></tr>")
document.write("</table>")
/* ]]> */
</script>
also you don't have to declare the array like
var day = [];
day[0] = "monday";
you can simply do
var day = ["monday"];
Upvotes: 1