I have a select that dynamically fill with data that I receive in a JSON, the user then chooses a value and continues using the application, I am trying to show that select again when I press a button I will appear with a predetermined option that is defined as "Choose board" but I can not change the selection from Javascript to show that option, I have this imlemented HTML:
<div id="tablaSelect">
<table id=tabla2 style="width:80%" >
<tr>
<th>
<div class="styled-select">
<select class="select" id="boards">
</select>
</div>
</th>
</tr>
</table>
Javascript to fill the select: // Mount the select with the boards
$('#boards')
.append($("<option></option>")
.attr("value",'')
.text("Elegir un tablero"));
$.each(boards, function(index, value) {
$('#boards')
.append($("<option></option>")
.attr("value",value.id)
.text(value.name));
arrayBoards.push(value.id);
});
Javascript to change the select:
function cambiar(){
document.getElementById("tablaSelect").style.display="block";
document.getElementById("select").value = '0'; //No se hace así porque no tengo values
}
Any ideas on how to make the select with the "Choose board" option when executing the change function? thank you very much:)