1
See is not popular a combo, I do. The combo is populated, then I need to take the id and show in the combo the text referring to that ID. The ID I have in my table, all that remains is to show the text in the combo. My jquery is like this:
function CarregaDados(ajaxParameter) {
$.ajax({
url: '/CadastroAcesso/CarregaDadosPagina',
datatype: 'json',
contentType: 'application/json;charset=utf-8',
type: 'POST',
data: JSON.stringify({ _nivel: ajaxParameter }),
success: function (data) {
$.each(data, function (index, itemData) {
$('#txtNome').val(itemData.NM_Usuario);
$('#txtUsuarioRede').val(itemData.Usuario1);
$('#txtEmail').val(itemData.Email);
//$('#cbxNivelAcesso').val();
});
},
error: function (error) {
}
})
}
cbxNivelAccess is my combo. It is commented, because I tested it in various ways and nothing.
Let me explain further. In my combo there are three records, with ID’s: 1, 2 and 3. When the ID = 3, the text should be shown is: ACTION. If the ID = 2 the text to be shown is: Query and if it is ID = 1 the text is: ADMINISTRATOR. This is what I cannot.
– pnet
This text should be shown where ? Copy your combo and glue it here please.
– vmontanheiro
In the combobox. Like this. There is a table and when the user gives a double click, there are four fields that will be filled to be edited and one of these fields is the combobox
– pnet
I think I get it, the person selects a value and you want it dynamically loaded in the combo ?
– vmontanheiro
If so, try to leave the combo selected as $("#cbxNivelAccess option[value='3']"). attr('Selected','Selected'); Ai no value you can swap the constant for a variable.
– vmontanheiro
Vinicius, that solves, now I can’t carry the Idnivel, because he’s a Foreign Key. But I will close this topic and try to resolve the other issue. If I can’t, I open another post.
– pnet
Answer Vinicius for me to close with your answer.
– pnet
This solved: $('#cbxNivelAccess option[value=' + itemData.Idnivel_access + ']'). attr('Selected', 'Selected');
– pnet
I’m sorry, buddy, I was in college. Too cool, if there’s anything else I can do to help you, you can be in charge.. But if not, please finish the post with a joinha. Hug ;)
– vmontanheiro
How do I put a joinha in my reply or comment to close the post?
– pnet
In my post you click the arrow up and just below it you will have an option to accept. : D
– vmontanheiro