I usually search and do not disturb the patience of the members here, but this time I specifically need an example. See:
<!DOCTYPE html>
<html>
<body>
<select id="lista" size="4">
<option value="A">01</option>
<option value="B">02</option>
<option value="C">03</option>
<option value="D">04</option>
<option value="E">05</option>
<option value="F">06</option>
<option value="G">07</option>
<option value="H">08</option>
<option value="I">09</option>
<option value="J">10</option>
<option value="k">11</option>
<option value="L">12</option>
</select>
<button onclick="somar()">Carregar Mais</button>
</body>
<script>
somar = function() {
var A = document.getElementById('lista');
var B = A.getElementsByTagName('option');
var C = B.length;
B.size = C;
}
</script>
</html>
Note that I'm starting the element select
with size [ size
] of 4 items sample, but what I want is something dynamic - auto height adjustment > of select
according to the amount of option
. That's why in the example function I'm trying to loop through the items using the documentgetElementsByTagName('option')
method. In my view, I thought this might be the solution to an increase when setting the size
property.
SUMMARY - Give way to automatically set the
size
property of the HTML element [select
] without human intervention, let the whole pro task "script" adjust to actual size. The idea is not to display the vertical scroll bar