Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You really should clean up your code by defining a function and then calling it from the button (like you did with the radio buttons) rather than sticking that long routine directly in the markup. You'll thank yourself down the road when you have to revisit this code to update it.</p> <p>The overall problem is how you're referencing the checkboxes. You have <code>this.form.admin</code> and it should be <code>this.document.form[0].admin</code>. In context, the <code>this</code> keyword is the <code>window</code> object, so you have to specify <code>.document</code> to get to the document and then access the <code>forms</code> array where your form is presumably the first element (<code>forms[0]</code>). Once you've referenced the form correctly, you can then access your checkboxes by name (<code>.admin</code>, <code>.security</code>, <code>.security1</code>).</p> <p>Also, as an aside, not that it matters in this case (since you're not using the <code>id</code> attributes), but per spec <a href="http://www.w3.org/TR/html401/types.html#type-name" rel="nofollow noreferrer"><code>id</code> attributes <strong>must</strong> begin with a letter</a>.</p> <p><strong>Working demo: <a href="http://jsfiddle.net/8VU7L/2/" rel="nofollow noreferrer">http://jsfiddle.net/8VU7L/2/</a></strong></p> <p>That said, you should probably access your inputs by <code>id</code> instead of DOM navigation to the <code>form</code> element. It's less fragile, more precise, and easier to read.</p> <p>As another aside, you may want to read <a href="https://stackoverflow.com/questions/2435525/best-practice-access-form-elements-by-html-id-or-name-attribute">Best Practice: Access form elements by HTML id or name attribute?</a>.</p> <p><strong>Working demo: <a href="http://jsfiddle.net/8VU7L/" rel="nofollow noreferrer">http://jsfiddle.net/8VU7L/</a></strong></p> <p>Finally, it may make your code more readable to use a bitfield (or rather, the JavaScript equivalent) for this kind of selection. In addition to readability, it's a snap to swap out messages for URLs using this technique.</p> <p><strong>Working demo: <a href="http://jsfiddle.net/8VU7L/1/" rel="nofollow noreferrer">http://jsfiddle.net/8VU7L/1/</a></strong></p>
    singulars
    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.
    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