Checkbox Text | JavaScriptSource

Checkbox Text

JavaScriptSource Staff Jul 20, 2000

General

The user no longer needs to click precisely on the checkbox to check and uncheck it. Clicking the text after the checkbox will also select it.


Clicking this text also checks the box to the left.

Notes

  • Posted: July 20, 2000

Source Code

Paste this source code into the designated areas.

External file

Paste this code into an external JavaScript file named: checkboxText.js


Head

Paste this code into the HEAD section of your HTML document.


Body

Paste this code into the BODY section of your HTML document


Leave a Response

(3 comments)

Yes, but there are times when that is not possible. For instance, when a table is being used for layout, and the label is in one cell and its associated control is in another cell.

Lee Nov 18, 2008

Just use the (X)HTML <label> tag to put focus onto a specific input object. For example:[br /]<input type="checkbox" name="checkboxName" id="checkme"> <label for="checkme">Select this checkbox</label>[br /][br /][br /]Problem solved! Now, all of your visitors (with or without JavaScript enabled) can click on the text.

Jeffrey Bennett Nov 17, 2008

nice script it solved my problem.

Siraj Ali Apr 2, 2008