Note that there are some explanatory texts on larger screens.

plurals
  1. POSelectbox disabled or enabled by an option of an other selectbox
    primarykey
    data
    text
    <p>I try to create a relation/connexion beetwen 2 selectbox</p> <pre><code>&lt;form id="creation" name="creation"&gt; &lt;select name="select01" id="select01"&gt; &lt;option value="01"&gt;01&lt;/option&gt; &lt;option value="02"&gt;02&lt;/option&gt; &lt;option value="03"&gt;03&lt;/option&gt; &lt;/select&gt; &lt;select name="select02" id="select02"&gt; &lt;option value="aa"&gt;aa&lt;/option&gt; &lt;option value="bb"&gt;bb&lt;/option&gt; &lt;option value="cc"&gt;cc&lt;/option&gt; &lt;/select&gt; &lt;/form&gt; </code></pre> <p>I want that my selectbox <strong>select02</strong> be disabled at the begening, and when i click on <strong>value02</strong> or <strong>value03</strong>, we enable it, and when we click on <strong>value01</strong>, disable it.</p> <p>There is my code js for the moment. I try to adapt it from an other function (radiobutton enabling a selectbox) but it doesn't seem to work. My list is disable at the beging, but the onclick is not working ...</p> <p>Some body can help me?</p> <pre><code>var oui = document.creation.select01[0]; document.getElementById("select02").disabled=true; oui.onclick = function() { document.getElementById("select02").disabled=false; } </code></pre> <p>Ok, so NOW, i'm with this code:</p> <pre><code>&lt;script&gt; var oui = document.select01; document.getElementById("select02" ).disabled=true; oui.onchange = function(){ document.getElementById("select02" ).disabled=false; } &lt;/script&gt; </code></pre> <p>I change the value of my selec01, then my select02 is now enable .. but how can I target only 2 options of my select01 ?</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.
 

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