I am playing about with javascript arrays.
Have recently just sat today looking through w3c and going through pages in a w3c book i bought on javascript and ajex and i was wondering whether you guys can help me on this little thing im playing on. someone suggested if im wanting to display stuff to use a drop down box but i need to learn to use arrays as the course im studying in college is on javascript and i feel this would be beneficial for me personally to know.
i want to know if its possible to as well as select data from the array but also to Input new data from a button that opens a prompt box for users to enter a new array object.
Code JavaScript:<SCRIPT language="JavaScript"> <!-- function p_Names() { var p_Names= new Array() p_Names["0"]="Player Number 0: Kyle Alexander"; p_Names["1"]="Player Number 1: Adam Mckenzie"; p_Names["2"]="Player Number 2: Lisa Rettie"; p_Names["3"]="Player Number 3: Jamie Scott"; p_Names["4"]="Player Number 4: Martyn Cooper"; p_Names["5"]="Player Number 5: Andrew Paterson"; var p_Disp=prompt("Please Chose a Number ",""); if ((p_Disp=="0") || (p_Disp=="1") || (p_Disp=="2") || (p_Disp=="3") || (p_Disp=="4") || (p_Disp=="5")) alert("You Chose "+p_Names[p_Disp]+"."); else alert("There are currently No Player Numbered" + '\n'+ p_Disp + '\n' + "Please Choose a Number again"); } //--> </SCRIPT> <FORM> <INPUT TYPE="button" onClick="p_Names()" value="Chose a Number"> </FORM>
Thanks for your help
Adam


Reply With Quote




Bookmarks