Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Elements from a Array 1

Status
Not open for further replies.

paulthorne

Technical User
Aug 30, 2000
1
GB
I have a simple phone book with a select box that display the persons first name and last name (there are about 4 enties in this select box), which it picks up from the (phonedb) array, it then displays this information in 2 text boxes called Firstname, and lastname. I have a button called remove and when i click on this i want it to delete the selected elements from the array

Any ideas

paul t
 
Paul,

This should work on the newer browsers...

Code:
<script language=&quot;javascript&quot;>
 var arrItems = new Array(&quot;Item 0&quot;, &quot;Item 1&quot;, &quot;Item 2&quot;, &quot;Item 3&quot;, &quot;Item 4&quot;)
 document.write(&quot;Before removal of Item 2: &quot; + arrItems + &quot;<br>&quot;)

//-----------------This removes stuff
 var arrDummy = arrItems.splice(2,1); /splice(start at index,number of items) place removed stuff in arrDummy
//-----------------

 document.write(&quot;After removal of Item 2: &quot; + arrItems + &quot;<BR>&quot;) 
</script>

Rob [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top