Jump to content

Select From Array


inktherapy

Recommended Posts

Hi.I managed to write a simple program that will store datas, select which data you want and display it.But what I want to do next is to display the datas that I did not select, separated from what I selected.e.g. My selected data: Van HalenThe datas that I did not select but I want to also view here: Mr. Big, Poison, Dream Theater, etc.I have my code here, please check hoping you could help me learn more thanks.

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>SelectFromArrays</title><script type="text/javascript">function storeEx() {var x = new Array();var y = 1;var z;var a;for (i=0; i<y; i++) {x[i] = prompt("Enter Data");z = confirm("Another data?");if (z == true) {y++;} else { a = parseInt(prompt("Enter Which Bank"));document.getElementById("display").innerHTML= x[a];}}}window.onload = storeEx;</script></head><body><div id="display"></div></body></html>

Link to comment
Share on other sites

You could loop through array x and simply filter out the one that's selected. A more permanent solution is to use array.splice() to remove the item that's selected. Then do whatever you want with the array.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...