setReadonly not working for type=select?

would like to set read only to some form fields;

thisField = name of the field
objForm = name of the form

  fieldType=objForm.getItemType(thisField);

if fieldType is “input” or “combo” everything works
if fieldType is “select” the following line will get an error “undefined is not a function”

objForm.setReadonly(thisField,true);

is there another possibility to set a select-item to read-only?
thank you in advance!

Hello,

Select in HTML doesn’t have a readonly attribute, but select has disabled attribute.

You can use

attachEvent("onChange",function (name, value){...}

Then inside onChange event set needed select index

myForm.getSelect("select_name").selectedIndex = 0;

or

myForm.setItemValue(name, NEEDED_value);

or your solution.

Hi

readonly not affect to select. this is input’s feature. if you want deny change options - you need to use another type of item.

wonderful, thanks! it’s working now!

fieldType=objForm.getItemType(thisField);
if (fieldType==“select”)
objForm.disableItem(thisField)
else
objForm.setReadonly(thisField,toLock);