Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript innerhtml return value
    text
    copied!<p>I am having trouble to understand this. I have this bit code:</p> <pre><code>document.getElementById("widget-container-1").innerHTML="&lt;div class='title'&gt;Select town: "+ "&lt;select id='drop'&gt;"+ "&lt;option name='Auckland' value='Auckland'&gt;Auckland&lt;/option&gt;"+ "&lt;option name='Christchurch' value='Christchurch'&gt;Christchurch&lt;/option&gt;"+ "&lt;option name='Dunedin' value='Dunedin'&gt;Dunedin&lt;/option&gt;"+ "&lt;option&gt;Hamilton&lt;/option&gt;"+ "&lt;option&gt;Tauranga&lt;/option&gt;"+ "&lt;option&gt;Wellington&lt;/option&gt;"+ "&lt;/select&gt;&lt;br /&gt;"+ "&lt;button id='update' name='update' onClick=\"this, _refreshWeatherDisplay(test);'\"&gt;update&lt;/button&gt;&lt;/div&gt;"+ "&lt;div class='monitor'&gt;Sort by"+ "&lt;input id='radio' name='input' type='radio' value='0' &gt;town"+ "&lt;input id='radio' name='input' type='radio' value='1' &gt;max temp"+ "&lt;div class='section'&gt;test&lt;/div&gt;&lt;/div&gt;"; select = document.getElementById("drop"); select.onchange = function(){ _checkNewTown(this.options[this.selectedIndex].text); }; </code></pre> <p>I want to get the data and perform another function:</p> <pre><code>var _checkNewTown = function(ntown){ alert(this.selectedIndex); } </code></pre> <p>But, in the -checkNewTown function is keep return indefined. And the button is not working when I try to alert it. </p> <pre><code>var _refreshWeatherDisplay = function(weather_info){ alert("test"); } </code></pre> <p>I know is could be simple, but I have no clue what I am doing wrong If anyone could help me will be very appreciatted.</p>
 

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