sanfly Posted February 14, 2006 Share Posted February 14, 2006 HiHow would i make something like this work[code]<script> 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"; alert(theText[num]); }</script><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>[/code]I keep getting "theText not defined" error message. CheersOops, this always happens. As soon as i ask the question, i figure out the answeri forgot to define the array[code]theText = new Array();[/code] Link to comment https://forums.phpfreaks.com/topic/3432-js-arrays-and-variables/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.