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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.