Re: Undefined Array Problem
Sorry, but that's javascript code, not Java code. While the two may look similar, they are in fact quite different. I've moved this to the Other Programming Languages forum on the off-chance that someone here knows Javascript, but you may want to consider finding a Javascript forum to ask you question on as they'd be better suited to answer your question.
Re: Undefined Array Problem
Hello,
The reason it prints out undefined is because you try to print whatever the randomBanner() method returns which is nothing or undefined.
You need to change your HTML slightly to this:
HTML Code:
<head>
<script type="text/javascript" src="rotator.js"></script>
</head>
<body>
<div id="banners">
<script type="text/javascript">randomBanner();</script>
</div>
</body>
See how the document.write has been removed since we don't need to print the output of the method because the method will change the innerHTML of that div anyway.
// Json