Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Array

Status
Not open for further replies.

hiyatran

Technical User
Aug 7, 2010
21
CA
I would like to display the elements in my array but it is NOT working. Here's my code:

Code:
<HTML>
<HEAD>
<TITLE>Test Input</TITLE>
<script type="text/javascript">

function addtext() {
   var openURL=new Array("[URL unfurl="true"]http://google.com","http://yahoo.com","http://www.msn.com","http://www.bing.com");[/URL]
   document.writeln('<table>');

   for (i=0;i<=openURL.length-1;i++){
      document.writeln('<tr><td>openURL[i]</td></tr>');
   }
   document.writeln('</table>');
}
</script>
</HEAD>
<body onload="addtext()">
</BODY>
</HTML>
Here's the ouput:
Code:
openURL[i] 
openURL[i] 
openURL[i] 
openURL[i]

It should display:
Code:
[URL unfurl="true"]http://google.com[/URL]
[URL unfurl="true"]http://yahoo.com[/URL]
[URL unfurl="true"]http://msn.com[/URL]
[URL unfurl="true"]http://bing.com[/URL]

Any comments or suggestions are greatly apprecitated.
thanks

 
Javascript doesn't automatically expand variables inside quotes.
Try:

Code:
document.writeln('<tr><td>[red]' + [/red]openURL[i] [red]+ '[/red]</td></tr>');

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top