Daniel is right, the construction of the markup is wrong.
However, what it's actually happening is that the label remains on top of
the checkbox and it doesn't let the click go through.

Once you fix the markup you should add the "for" attribute to the label to
make it work properly. Since you are generating everything from js, just
add:
vmc_label.setAttribute("for", "vmc");

Ernest


On Tue, Dec 29, 2009 at 8:22 PM, Daniel Wagner-Hall <[email protected]>wrote:

> The problem is that you're appending the label to the checkbox
> element, not the table cell, so when you are clicking on the checkbox,
> you are clicking on both the checkbox AND the label, so it keeps its
> current state.
>
> Change the line:
> vmc_box.appendChild(vmc_label);
> to:
> vmc_element.appendChild(vmc_label);
> and it will work.  You may want to swap the order of appending the
> label and the box, for consistency with the option above.
>
> On Tue, Dec 29, 2009 at 10:14 PM, FractalBob <[email protected]> wrote:
> > Hi,
> >
> > My content script creates a checkbox OK, but when I try to manually
> > change the state, nothing happens. Here's the code:
> >
> > var tables = document.getElementsByTagName("table");
> > var checkbox_tbl = tables[tables.length - 2];
> >
> > var vmc_row = document.createElement("tr");
> > vmc_row.vAlign = "top";
> > var vmc_element = document.createElement("td");
> >
> > var vmc_box = document.createElement("input");
> > vmc_box.id = "vmc";
> > vmc_box.type = "checkbox";
> > vmc_box.name = "vmc";
> > vmc_box.checked = "checked";
> >
> > var vmc_label = document.createElement("label");
> >
> > vmc_label.appendChild(document.createTextNode
> > ("\u00a0\u00a0\u00a0\u00a0Post\u00a0this\u00a0message\u00a0as
> > \u00a0virtual\u00a0mail\u00a0content"));
> > vmc_box.appendChild(vmc_label);
> > vmc_element.appendChild(vmc_box);
> > vmc_row.appendChild(vmc_element);
> > checkbox_tbl.appendChild(vmc_row);
> >
> >
> > Thanks.
> >
> > Bob
> >
> > --
> >
> > You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> > To post to this group, send email to
> [email protected].
> > To unsubscribe from this group, send email to
> [email protected]<chromium-extensions%[email protected]>
> .
> > For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
> >
> >
> >
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Chromium-extensions" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<chromium-extensions%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/chromium-extensions?hl=en.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Chromium-extensions" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/chromium-extensions?hl=en.


Reply via email to