When going through an array, I fill in a select automatically, if two values coincide, I make that value be the one that remains as selected in the select. This works but the problem I have is that when taking the value of the select, it also takes the word selected( valueselected)
idElemento=$("#idElemento").val();
The value of the idElemento would be:objJsonEle[i].idselected
$('#idElemento').append("<option value= " + objJsonEle[i].id + "selected >" + " " + objJsonEle[i].name + "</option>");
you have the problem because you have to indicate the value, in your case, with single quotes, being like this:
$('#idElemento').append("<option value= '" + objJsonEle[i].id + "' selected >" + " " + objJsonEle[i].name + "</option>");
In this way, you will not have that problem
Once the select is filled with the value selected you should be able to access it with
$('#idElement').val()