Note that there are some explanatory texts on larger screens.

plurals
  1. POIE9 Standards Document Mode Breaks JavaScript
    primarykey
    data
    text
    <p>I have generated some JS code on a web page to calculate the correct amount of days to display on a date drop-down box of a form depending on leap year and month. Unfortunately, I've noticed that in IE9 Standards Document mode, the drop-down does not appear to display the date numbers (e.g. 1 through 31). IE 10, Firefox v.25.0.1, and Google Chrome v.31.0.1650.63 display the numbers in the drop-down correctly. I imagine I have some code that is not supported in older document modes, but cannot seem to find where it would be. I'm hoping someone may be able to spot my mistake(s)? I've included the relevant code below. Please note that I am running the document with the HTML5 !DOCTYPE.</p> <p><strong>JS Functions:</strong></p> <pre><code>&lt;script&gt; function is_leap(direction) { if(direction=="from") var year=document.getElementById("f_year").value; else if(direction=="to") var year=document.getElementById("t_year").value; var a = 2000; for(a;a&lt;year;a+=4) { } if(a==year) { return true; } else return false; } function out_days(v,direction) { var html = ""; for(var x=1;x&lt;=v;x++) { html += '&lt;option value="' + x + '"&gt;' + x + '&lt;/option&gt;'; } if(direction=="from") { var temp_day=document.getElementById("f_day").selectedIndex; document.getElementById("f_day").innerHTML=html; document.getElementById("f_day").selectedIndex=temp_day; } else if(direction=="to") { var temp_day=document.getElementById("t_day").selectedIndex; document.getElementById("t_day").innerHTML=html; document.getElementById("t_day").selectedIndex=temp_day; } } function chk_mon(direction) { if(direction=="from") var e = document.getElementById("f_month").selectedIndex; else if(direction=="to") var e = document.getElementById("t_month").selectedIndex; switch(e) { case 0: case 2: case 4: case 6: case 7: case 9: case 11: { out_days(31,direction); break; } case 1: { if(is_leap(direction)) { out_days(29,direction); } else out_days(28,direction); break; } case 3: case 5: case 8: case 10: { out_days(30,direction); break; } default: { out_days(31,direction); break; } } } &lt;/script&gt; </code></pre> <p><strong>HTML Calling Code/Functions:</strong></p> <pre><code>&lt;div class="field"&gt;&lt;div class="label"&gt;From:&lt;/div&gt;&lt;select onchange="chk_mon('from')" id="f_month" name="from_month"&gt; &lt;option value="1"&gt;January&lt;/option&gt; &lt;option value="2"&gt;February&lt;/option&gt; &lt;option value="3"&gt;March&lt;/option&gt; &lt;option value="4"&gt;April&lt;/option&gt; &lt;option value="5"&gt;May&lt;/option&gt; &lt;option value="6"&gt;June&lt;/option&gt; &lt;option value="7"&gt;July&lt;/option&gt; &lt;option value="8"&gt;August&lt;/option&gt; &lt;option value="9"&gt;September&lt;/option&gt; &lt;option value="10"&gt;October&lt;/option&gt; &lt;option value="11"&gt;November&lt;/option&gt; &lt;option value="12"&gt;December&lt;/option&gt; &lt;/select&gt; &lt;select id="f_day" name="from_day"&gt; &lt;script&gt; chk_mon("from"); &lt;/script&gt; &lt;/select&gt; &lt;select onchange="chk_mon('from')" id="f_year" name="from_year"&gt; &lt;option value="2013"&gt;2013&lt;/option&gt; &lt;option value="2014"&gt;2014&lt;/option&gt; &lt;option value="2015"&gt;2015&lt;/option&gt; &lt;option value="2016"&gt;2016&lt;/option&gt; &lt;option value="2017"&gt;2017&lt;/option&gt; &lt;option value="2018"&gt;2018&lt;/option&gt; &lt;option value="2019"&gt;2019&lt;/option&gt; &lt;option value="2020"&gt;2020&lt;/option&gt; &lt;option value="2021"&gt;2021&lt;/option&gt; &lt;option value="2022"&gt;2022&lt;/option&gt; &lt;option value="2023"&gt;2023&lt;/option&gt; &lt;option value="2024"&gt;2024&lt;/option&gt; &lt;option value="2025"&gt;2025&lt;/option&gt; &lt;option value="2026"&gt;2026&lt;/option&gt; &lt;option value="2027"&gt;2027&lt;/option&gt; &lt;option value="2028"&gt;2028&lt;/option&gt; &lt;option value="2029"&gt;2029&lt;/option&gt; &lt;option value="2030"&gt;2030&lt;/option&gt; &lt;/select&gt;&lt;/div&gt; </code></pre>
    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