Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a lot of ways you could do this. The most straightforward would be to just put a checkbox next to each paragraph. The user can check the boxes next to the paragraphs of his choosing.</p> <p>If you have a smoother interface in mind, you can extend that idea by hiding the checkboxes with CSS, then using JavaScript to <del>make the checkboxes selected when the corresponding paragraph is clicked and</del> highlight the paragraph (by applying a CSS class) to show it as selected. A framework like jQuery will streamline this process nicely.</p> <p><strong>Edit:</strong> Now that I think of it, as long as you put each paragraph in a <code>&lt;label&gt;</code> element you don't even need JavaScript to check/uncheck the hidden checkboxes; that will happen automatically as long as the label's <code>for</code> attribute is set correctly. All you need JavaScript for is to highlight/unhighlight the labels.</p> <p>Here's a naive implementation using jQuery:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; input.hidden-checkbox { display: none; } label.multi-select { display: block; cursor: pointer; } label.checked { background-color: #ddd; } &lt;/style&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('input.hidden-checkbox').bind('change', function(e) { var checkBox = $(e.target), label = $('label[for=' + checkBox.attr('id') + ']'); if(label) { if(checkBox.attr('checked')) { label.addClass('checked'); } else { label.removeClass('checked'); } } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;input type="checkbox" value="1" name="paragraph[]" id="paragraph-1" class="hidden-checkbox"/&gt; &lt;label for="paragraph-1" class="multi-select"&gt;Text of paragraph 1. As long as you want. Lorem ipsum dolor sit amet...&lt;/label&gt; &lt;input type="checkbox" value="2" name="paragraph[]" id="paragraph-2" class="hidden-checkbox" class="multi-select" /&gt; &lt;label for="paragraph-2" class="multi-select"&gt;Paragraph 2's text. Lorem ipsum dolor sit amet...&lt;/label&gt; &lt;!-- ...etc... --&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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