0

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>

1 Answer 1

1

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"];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.