tags:

views:

180

answers:

3

function abc() { document.form1.1.disabled=true; }

I have a select box whose id is 1 in html page.I am using javascript as above but it is not disabling the select box

+2  A: 

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

http://www.w3.org/TR/html4/types.html#type-name

Fix the underlying problem. Don't have ids that start with a number.

David Dorward
A: 

document.form1 contains a list of input elements, selectboxes and textareas. document.form1.1 is the same as saying document.form1[1] and gets the second element in that list. Try

document.getElementById("1").disable = true;
Marius
+1  A: 
var elem = document.getElementById("1");
elem.setAttribute("disabled","disabled");
TheVillageIdiot