3
I wonder how I get the value of a <select>
dynamic, ie when I modify the value it presents me this value, I imagine something like below, someone could help me?
varItens = document.getElementById('caminhos');
for( i = 0;i < varItens.length;i++)
{
varItens.options[i].selected = true;
alert( varItens.options[i].id );
}
But it doesn’t work, because I know this was if it was static.
Do you want to take the value selected by the user or all the values of the select? In your example you are trying to select everyone and trying to display the
ID
ofoption
, that will probably always benull
.– Richard Dias
would be from each option when it was selected
– Marcos Henrique
To do this the @Danilo answer is correct, as long as you can use jquery, as it is in the question tags.
– Richard Dias