0
I need to set the description (EnderecoTipoDescricao
) and the icon (icon fa-home
) at the event change
of a SELECT
. For each Row the "Addressdescription" field has an id whose index is incremented: id="panel-title[i] going from 0 to ... . When selecting an option in select, I take the Row Index and with it I can set the id field id="panel-title[i] corresponding to Row. I don’t know how to set the text and the current description icon according to the option selected in the selection (delivery or Other). Someone knows how to do it?
RAZOR
<h3 class="panel-title" id="panel-title[i]"><i class="icon fa-home" aria-hidden="true"></i>@Model.PessoasEnderecosViewModel[i].EnderecoTipoDescricao</h3>
<div class="col-md-4">
<label asp-for="PessoasEnderecosViewModel[i].EnderecoTipoId" class="control-label lb-endereco-tipo">Tipo de Endereço</label>
<select asp-for="PessoasEnderecosViewModel[i].EnderecoTipoId" asp-items="@Model.PessoasEnderecosViewModel[i].EnderecosTipos" data-id="@Model.PessoasEnderecosViewModel[i].EnderecoTipoId" title="Selecione uma opção" class="form-control sel-endereco-tipo"><option value=""></option></select>
<span asp-validation-for="PessoasEnderecosViewModel[i].EnderecoTipoId" class="text-danger val-endereco-tipo"></span>
</div>
JS
$('#div-enderecos').on("change", ".sel-endereco-tipo", function (e) {
e.preventDefault();
//Pegar o índice
var rowIndice = $(this).closest('.row').index();
//Setar o texto e o ícone do field panel-title[rowIndice ]???????????
});
OPTIONS IN THE SELECT
1 - DELIVERY (CHANGE ICON TO fa-truck icon) 2 - OTHER (CHANGE ICON TO icon glyphicon glyphicon-Pushpin)
Question not made clear
SELECT
on that question? what do you really want to do?– novic