Copying Select contents with slice -possible?

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
coolin
Forum Newbie
Posts: 21
Joined: Sun Mar 16, 2008 1:44 pm

Copying Select contents with slice -possible?

Post by coolin »

I have been trying to copy a select dropdown's contents into a new array directly using the JS slice command but as this is not working I am wondering if this is correct & should work or if it is an incorrect syntax. (My aim is to copy the entire contents of select preferrably without using a loop into a new array that does not change with the original select's contents)

Tried code here

Code: Select all

var tryz = selecta.slice();
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Copying Select contents with slice -possible?

Post by Christopher »

You need to loop through all the option elements and put the values into an array first.
(#10850)
Post Reply