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] Quote Link to comment https://forums.phpfreaks.com/topic/3432-js-arrays-and-variables/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.