Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot set property error in javascript
    primarykey
    data
    text
    <p>so i have this code that checks for dates and updates lists accordingly, now what i am trying to achieve is that when the for both the month and the year are set to null "mm" "yyyy" is set the day select list with one element "dd" with a value of null. but i have been having an error cannot set property 'value' of undefined. The first element in both the year and month s is set to a value of null.</p> <p>this is the javascript function a guy here helped me come up with:</p> <pre><code>function monthDays (type) { if(document.getElementById('monthof' + type).value == null || document.getElementById('yearof' + type).value == null) { var mod = document.getElementById('dayof' + type); mod.length = 1; mod[0].value = null; mod[0].text = "DD"; } else{ var month = parseInt(document.getElementById('monthof' + type).value, 10), days = new Date(document.getElementById('yearof' + type).value, month + 1, 0).getDate(), i; var mod = document.getElementById('dayof' + type); mod.length = days + 1; mod[0].value = null;//this is where i am getting the error mod[0].text = "DD"; for(i = 1; i &lt; days+1; i++) { mod[i].value = i; mod[i].text = i; } } } </code></pre> <p>html Birth: MM </p> <pre><code>&lt;select id="dayofbirth" class="date" name="dayhofbirth"&gt; &lt;option value=null&gt;DD&lt;/option&gt; &lt;/select&gt; &lt;select id="monthofbirth" class="year" name="monthofbirth" onchange="monthDays('birth')"&gt; &lt;option value=null&gt;MM&lt;/option&gt; &lt;/select&gt; &lt;select id="yearofbirth" class="year" name="monthofbirth" onchange="monthDays('birth')"&gt; &lt;option value=null&gt;YYYY&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>the type is there to tell the function which it should edit, since in my html I have 2 date of births.</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.
 

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