select html
<select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
select html
<select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
select html
const showSelect = function(){
text = select.options[select.selectedIndex].textContent;
label.innerHTML = textVisible == select.value ?
`Opción seleccionada ${text} <br> NO tiene atributo "value" asignado` :
`Opción seleccionada "${text}" <br> SI tiene atributo "value" igual a "${select.value}"`;
};
const findValue = function(value){
result = -1;
let index = 0;
while(!result & index < select.options.length){
if(option.value == value) result = index;
index++;
}
return result;
}
const findText = function(value){
result = -1;
let index = 0;
while(!result & index < select.options.length){
if(option.textContaint == value) result = index;
index++;
}
return result;
}
const removeValue = function(value){
result = false;
index = findValue(value);
if(index){
select.remove(index);
result = true;
};
return result;
}
const removeText = function(value){
result = false;
index = findText(value);
if(index){
select.remove(index);
result = true;
};
return result;
};
showSelect();
select.addEventListener('change', function(){
showSelect();
});
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us