Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've coded a quick example to show you how this would be done. First you will need to set up your java app to allow ajax calls. The java app will need to take in as input a single post variable name <code>selected</code> which is the value of the selected option in the dropdown menu. The java app will then need to return a json string formatted similar too:</p> <pre><code>{ "disabled":[ "1", "3", "5" ] } </code></pre> <p>The 1, 3, and 5 represent the ids of the checkboxes you would like to be disabled. These can be any ids of any of the checkboxes. If it isn't in this array, it <em>will</em> be set to enabled by default.</p> <p>HTML:</p> <pre><code>&lt;select id="choiceSelector"&gt; &lt;option value="1"&gt;Something 1&lt;/option&gt; &lt;option value="2"&gt;Something 2&lt;/option&gt; &lt;/select&gt; &lt;br/&gt;&lt;br/&gt; &lt;div id="changingCheckboxes"&gt; &lt;input type="checkbox" name="" id="1"&gt;&lt;br/&gt; &lt;input type="checkbox" name="" id="2"&gt;&lt;br/&gt; &lt;input type="checkbox" name="" id="3"&gt;&lt;br/&gt; &lt;input type="checkbox" name="" id="4"&gt;&lt;br/&gt; &lt;input type="checkbox" name="" id="5"&gt;&lt;br/&gt; &lt;input type="checkbox" name="" id="6"&gt; &lt;/div&gt;​ </code></pre> <p>Javascript/jquery</p> <pre><code>function UpdateCheckBoxStatus () { var CurrentChoice = $('#choiceSelector').val(); $.ajax({ url: "####YOUR JAVA APP URL####", data: { "selected": CurrentChoice }, type: "post", dataType: "json", success: function (data) { SetCheckbox($('#changingCheckboxes').children("input:[type='checkbox']"), true); $.each(data.disabled, function () { SetCheckbox($('#changingCheckboxes #' + this), false); }); } }); } /// Sets the checkbox to enabled or disabled /// @param th Jquery reference of one or more checkboxes /// @param usable True/False if the checkbox is enabled/disabled function SetCheckbox (th, usable) { if (usable) th.removeAttr("disabled"); else if (!usable) th.attr("disabled", true); } $(function () { $('#choiceSelector').change(UpdateCheckBoxStatus); UpdateCheckBoxStatus(); //run for page load }); </code></pre> <p>Also, here is the jsfiddle of it: <a href="http://jsfiddle.net/bpstw/1/" rel="nofollow">http://jsfiddle.net/bpstw/1/</a></p> <p>Hope that helps.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. 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