Page 1 of 1

Copying Select contents with slice -possible?

Posted: Tue Apr 21, 2009 8:13 am
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();

Re: Copying Select contents with slice -possible?

Posted: Tue Apr 21, 2009 12:14 pm
by Christopher
You need to loop through all the option elements and put the values into an array first.