After selecting 5 and 2, does any solution for how could get a string output like: 5 greater than 2 ?
<p class="showTxt" id="showTxt">
<select size="2">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<p> greater than</p>
<select size="1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</p>
Is this what you want?
function showText(ele) {
document.getElementById("2").innerHTML = document.getElementById("1").options[document.getElementById("1").selectedIndex].text+" is greater than "+ele.options[ele.selectedIndex].text;
}
<p class="showTxt" id="showTxt">
<select size="2" id="1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<p> greater than</p>
<select size="1" onchange="showText(this)">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</p>
<p id="2"></p>