a question about a small clause.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
M.K_Soft
Forum Newbie
Posts: 6
Joined: Sat Dec 19, 2009 2:01 pm

a question about a small clause.

Post 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.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: a question about a small clause.

Post 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
Post Reply