Page 1 of 1

a question about a small clause.

Posted: Sat Dec 19, 2009 2:24 pm
by M.K_Soft
hi dears.
forgive me if it's not the proper topic. i'm new comer.
i have a small question.

Image

in the above image, how i can bound my last input box to the check box? i mean when i checked it, the input box enabled get true and reverse.
thank you in advance.

Re: a question about a small clause.

Posted: Sun Dec 20, 2009 7:12 am
by kaszu
Assuming you have HTML something like this

Code: Select all

<input type="checkbox" id="checkCourse" ... />
... <input type="text" id="textCourse" disabled="disabled" ... />
Javascript will be

Code: Select all

var fn = function () {
    document.getElementById('textCourse').disabled = this.checked;
};
document.getElementById('checkCourse').onchange = fn;
document.getElementById('checkCourse').onclick = fn; //onclick needed for IE, because 'change' event is only fired when input looses focus