View Full Version : Using .splice on form elements.

06-17-2010, 12:12 PM
Here is the code in question:

for (var x = 2; x < 6; x++) {
var form = document.playerAction["action" + proNum];
form[x] = null;
form[x] = z[x-2];
if (Player[x-1].health == 0) { form.splice(x-2,1) }

The code retrieves document.playerAction["action1"] (A select input type) and removes options 2-end (there is a max of 6). Then, if a certain player (x-1 causes it to loop 1-4) has a health of 0, it splices out that element).

Everything works fine, except I get an error saying that
"Object #<an HTMLSelectElement> has no method 'splice' "
and it refuses to execute the if.

How do I work around this?