Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Variable <code>str22</code> is not being assigned when you call <code>showBlock2()</code> on changing year. So replace the line</p> <pre><code>showB(); </code></pre> <p>with</p> <pre><code>showB(document.getElementsByName("h")[0].value); </code></pre> <p>This would work when you select health and then year, no need to call showB() on changing health list. </p> <p><strong>EDITED (Optimized Code):</strong></p> <p>The following code has been altered from your source.</p> <p><strong>Mainpage</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function showBlock2() { var str11=document.getElementsByName("h")[0].value; var str22=document.getElementsByName("yr")[0].value; document.getElementById("txtHint").innerHTML=""; var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getblock2.php?q="+str11+"&amp;h="+str22,true); xmlhttp.send(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; Select a Health block &lt;select name="h" onChange="showBlock2()"&gt; &lt;option value="1"&gt;H1&lt;/option&gt; &lt;option value="2"&gt;H2&lt;/option&gt; &lt;/select&gt; &lt;br/&gt; Select a year &lt;select name="yr" onChange="showBlock2()"&gt; &lt;option&gt;2012&lt;/option&gt; &lt;option&gt;2013&lt;/option&gt; &lt;/select&gt; &lt;div id="txtHint" style="width:570px; height:auto" &gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Note that only <code>function showBlock2()</code> is used for onchange on both dropdowns, so the div <code>txtHint</code> is updated at each change. Also no parameters passed.</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. 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