Note that there are some explanatory texts on larger screens.

plurals
  1. POIE problem: keyboard interaction with checkbox
    primarykey
    data
    text
    <p>I have an HTML table, and each row has a checkbox for selecting or deselecting its row. Whenever a checkbox changes value, I need to add or remove highlighting to the row and also ensure that the page's submit button is only enabled when at least one row is selected and disabled otherwise.</p> <p>The checkbox event handler is defined by the following function:</p> <pre><code>function getCheckboxCallback() { return function () { var parentRow = getParentRow(this); if (!parentRow) { return; // No parent row found; abort } // Adjust the appearance of the row setSelected(parentRow, this.checked); // Count the number of selected table rows, and disable the submit // button whenever no rows are selected enforceInvariants(); return true; }; } </code></pre> <p>Elsewhere in the same module, the checkboxes are given the event handlers:</p> <pre><code>checkbox.onchange = getCheckboxCallback(); checkbox.onclick = getCheckboxCallback(); // alleged IE fix </code></pre> <p>I'm working in Windows XP, and everything works fine in both Firefox 3 and Opera 9. However, IE 7 does not handle keyboard interaction well (mouse interaction works fine).</p> <p>The problem is that if a checkbox has the focus and I hit the spacebar, the checkbox doesn't get checked -- instead it gets half checked (it has the same shadowed appearance that it would get immediately after a mousedown). I have to press the spacebar a second time to actually check the box. Similarly, it requires two key presses to uncheck it. Oddly enough, if I hold down the spacebar for a few moments, then a single press works as expected.</p> <p>Can anyone explain what is going on here? Is there something I'm doing wrong in the JavaScript code that is causing this behavior? How can I fix this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload