Jump to content


JS arrays and variables

  • Please log in to reply
No replies to this topic

#1 sanfly

  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 14 February 2006 - 10:44 PM


How would i make something like this work


    function showMore(num){
        theText[0] = "this is 0";
        theText[1] = "this is 1";
        theText[2] = "this is 2";
        theText[3] = "this is 3";
        theText[4] = "this is 4";
        theText[5] = "this is 5";

<a href="#" onclick="showMore('0'); return false;">0</a><br>
<a href="#" onclick="showMore('1'); return false;">1</a><br>
<a href="#" onclick="showMore('2'); return false;">2</a><br>
<a href="#" onclick="showMore('3'); return false;">3</a><br>
<a href="#" onclick="showMore('4'); return false;">4</a><br>
<a href="#" onclick="showMore('5'); return false;">5</a><br>

I keep getting "theText not defined" error message.


Oops, this always happens. As soon as i ask the question, i figure out the answer

i forgot to define the array

theText = new Array();

If you're not part of the solution, you're part of the precipitate

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users