we would do it this way
br>
<script language="JavaScript" type="text/javascript">
function func() {
var HorizontalLinks=[['Yahoo','www.yahoo.com' ,'Yahoo'],['AOL','www.aol.com','AOL'],['T. J. jay','www.geocities.com','My Site']];
var stri ;
for (var i=0; i<HorizontalLinks.length; i++)
{
document.getElementById('iner').innerHTML += "http://"; + HorizontalLinks[i][1] + "">" + HorizontalLinks[i][0] + "
";
stri = "" ;
}
}
</script>
<body onload="func()">
<div id="iner">
</div>
</body>
we would make a function out of it and call it when the page loads. However note the ' += ' string concatenate operator. this is because everytime we use the innerHTML function, it writes the whole of the contents of the 'div' with id 'iner'. The old content of 'iner' is replaced, not added to.
trshant
----- Original Message ----
From: Aaron L. < elmastero74%40gmail.com">elmastero74
gmail.com>
To: 1stJavaScript%40yahoogroups.com">1stJavaScript
yahoogroups.com
Sent: Wednesday, 17 October, 2007 7:53:16 PM
Subject: Re: [1stJavaScript] first array for link building
Nice work, Alligator.
Just out of curiosity, how could one do this using innerHTML instead of
document.write?
-a
On 10/16/07, Alligator < alligator_666%40yahoo.com">alligator_666
yahoo.com> wrote:
>
> You are closing document.write in the wrong place:
> document.write('http://' + HorizontalLinks[i][1]) ......
>
> This should work:
> <script type='text/javascript'>
> <!--
>
> function printLinks() {
> var HorizontalLinks = [ ["Yahoo" , "www.yahoo.com"; , "Yahoo"],
> ["Mental Health", "www.MH.Alabama.GOV";, "ADMH"],
> ["T. J. jay", "www.MH.Alabama.GOV";, "My Site"] ];
>
> for (var i = 0; i < HorizontalLinks.length; i++) {
> document.write('' +
> HorizontalLinks[i][0] + '</a><br/>');
> }
> }
>
> // -->
> </script>
>
> Alligator_666
> http://www.vicxsite.com/
>
> Smokey < tjjay%40yahoo.com">tjjay
yahoo.com <tjjay%40yahoo.com>> wrote: Greetings, all,
>
> my first attempt at array building and then writing as links
>
> -------------source follows----------
>
> <script type="text/javascript">
>
> var HorizontalLinks=new Array()
>
> /* <a title="screen tip" href="#1">displayed title</a> */
>
> HorizontalLinks[0]=["Yahoo", "www.yahoo.com";, "Yahoo"]
> HorizontalLinks[1]=["Mental Health", "www.MH.Alabama.GOV";, "ADMH"]
> HorizontalLinks[2]=["T. J. jay", "www.MH.Alabama.GOV";, "My Site"]
>
> for (i=0; i<HorizontalLinks.length; i++)
>
> {
>