468,253 Members | 1,308 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

Arrays, Array scope, etc.

Given the code below I think I should get an alert message box that
says "one" when the link is clicked - but instead i get an error that
"x.1 is null or not an object"

Thanks for any help

- tom

<script language="JavaScript">
var x = new array();

x[0] = "zero";
x[1] = "one";

function z()
{
alert(x[1]);
}

</script>
<html>
<body>
<a href="javascript: z();">click here</a>
</body>
</html>

Jul 23 '05 #1
2 3103
"harborcoat-design" <tj******@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Given the code below I think I should get an alert message box that
says "one" when the link is clicked - but instead i get an error that
"x.1 is null or not an object"

Thanks for any help

- tom

<script language="JavaScript">
var x = new array();

x[0] = "zero";
x[1] = "one";

function z()
{
alert(x[1]);
}

</script>
<html>
<body>
<a href="javascript: z();">click here</a>
</body>
</html>


Try
var x = new Array();
not
var x = new array();
Jul 23 '05 #2
doh

thanks

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

21 posts views Thread by Matteo Settenvini | last post: by
32 posts views Thread by santosh | last post: by
4 posts views Thread by Olumide | last post: by
127 posts views Thread by sanjay.vasudevan | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.