Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

95
Visualizações
Show multiple instances of div synchronous according to number of elements in select list

I have a select list that gets items from the datababase where we can add other items to it from an other list or delete items in it,

 <div class="form-group col-md-3">
 <label for="IX">Selected Issuing Banks</label>     
<select id="IX" name="IX" multiple="multiple" style="width: 250px; height: 70px; margin: 0px 2px 0px 3px;" data-bind="options: IX, optionsText: function(item) { return item.Name +' (' + item.BICCode + ')' }, optionsValue: 'Id',value: IdIX"></select>
</div>

And just after the selectlist, I have a div with multiple textfields to insert into the database, I want to show multiple numbers of this same div synchronously according to the items in the select, if the list essentially has 2 times we'll have this div shown twice, if we add another item to the list it will become 3 times and I am having trouble with making this

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The trick will be in naming elements but jquery .each() should get you started:

$("#IX option").each(function () {
    $("body").append($("#fieldsDiv").html());
});

I'd recommend using a content template and dynamically build the new divs based on it:

<div class="divContainer">
</div>

<template id="fieldsDivTemplate">
    <div class="fields">
        <!-- your fields go here use {{tags}} as placeholders for id values -->
    </div>
</template>

<script>
    $(function () {
        let t = $("#fieldsDivTemplate").html();
        t = t.replace(/{{tags}}/g, "value from select list item goes here");

        body.append(t);
    });
</script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda