Note that there are some explanatory texts on larger screens.

plurals
  1. POadd option fields between <select> and </select>
    text
    copied!<p>I have a day &lt;SELECT&gt; field and a month &lt;SELECT&gt; field, and the day &lt;SELECT&gt; should contain the month's days number of &lt;OPTION&gt;s. for exemple if I choose April from month &lt;SELECT&gt; the number of &lt;OPTION&gt;s in the day &lt;SELECT&gt; is 30. My question is: how can I add an &lt;OPTION&gt; field between the &lt;SELECT&gt; and &lt;/SELECT&gt;?</p> <p>this is the HTML code:</p> <pre><code>&lt;div class="input"&gt; &lt;label&gt;Date de naissance&lt;/label&gt; &lt;br&gt; &lt;select name="jour"&gt;&lt;/select&gt; &lt;select name="mois" onchange="ajouterJours(this.options[this.selectedIndex].text);"&gt;&lt;/select&gt; &lt;input type="number" name="annee"&gt; &lt;/div&gt; </code></pre> <p>and this is the JS script I've created so far:</p> <p>his is the function which gonna work on the load of the page :</p> <pre><code>function main() { var i = 0; var moisSelect = form.mois; while (i&lt;12) { i++; moisSelect // here I cant figure out what to do with the month SELECT to add options } } </code></pre> <p>And this is the function which add options between &lt;SELECT&gt; and &lt;/SELECT&gt; for the day &lt;SELECT&gt; field:</p> <pre><code>function ajouterJours(mois) { var mois = 0; var jourSelect = form.jour; switch(mois) { case 1,3,5,7,8,10,12: mois = 31; break; case 2: mois = 29; break; case 4,6,9,11: mois = 30; } var i = 0; while (i&lt;m) { i++; jourSelect // here I cant figure out what to do with the day SELECT to add options } } </code></pre>
 

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