[thelist] hyperlinks on label tags?

Ryan Rushton web at ryanrushton.com
Mon Sep 25 18:50:11 CDT 2006

I have a page that displays a list of categories with a checkbox + label 
for each category and an onChange action on each checkbox.

The labels of categories that contain sub-categories are hyperlinked.  
When a user clicks the hyperlink to drill into the category, the 
checkbox is also getting checked/un-checked causing undesirable results.

Is there a way to use javascript to prevent the box from being 
checked/unchecked when the label is/contains a hyperlink?

Here is a sample of the current HTML ...

<!-- with hyperlink -->
<input type="checkbox" name="selectedCatId" id="category01" value="01" 
<label for="category01">
  <a href="categorySelector.do">Category 01</a>

<!-- no hyperlink -->
<input type="checkbox" name="selectedCatId" id="category02" value="02" 
<label for="category02">
  Category 02

More information about the thelist mailing list