Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

Make select tag enabled or not

1 réponse
Avatar
phpounch
Hello,

I would like to know how to enable or disable a select box when I click on a
checkbox!?
I tried several ways but none does what I want!

Here is my code:
/**********************************/
function setPrimaryCategory(checkb) {
f = document.getElementById("c_form");
if (checkb.checked) {
f.c_primcat.enabled = false;
}
else {
doSomething()
}
}
/**********************************/

What do you think?
Thanks,
Dams

1 réponse

Avatar
Olivier
"phpounch" wrote in
news:40d6b34c$0$23518$:

Hello,

I would like to know how to enable or disable a select box when I
click on a checkbox!?
I tried several ways but none does what I want!

Here is my code:
/**********************************/
function setPrimaryCategory(checkb) {
f = document.getElementById("c_form");
if (checkb.checked) {
f.c_primcat.enabled = false;
}
else {
doSomething()
}
}
/**********************************/

What do you think?
Thanks,
Dams


Hello,

Huh, you're on a french newsgroup ^^
But I'll answer your question :
The property which allows to enable/disable an <input> or <select>
element is "disabled", not "enabled".
So, instead of writing that :
f.c_primcat.enabled = false;
you should write that :
f.c_primcat.disabled = true;

Bye
O.L.