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

170
Visualizações
How to put array response into input box?

Hi i needed help off putting an array into the input box value display below

This is how my array response is

[{"CollectionFirstDate": "2021-12-15", "StartDay": 1, "EndDay": 6}]

I woud like that this array is put into my input box

2021-12-15 = DateoffirstcollectionDisplay
StartDay": 1, "EndDay": 6  = dayrange

How can i do that ?

<div class="mb-3 StyleFormRestRight dateoffirstcollection">
  <label for="CollectionType" class="col-3 form-label"><b class="Dateoffirstcollection">Date of first collection</b></label>
  <br/>
  <input type="text" class="col-2 form-control" id="DateoffirstcollectionDisplay" disabled readonly>
</div>

<div class="mb-3 StyleFormRestRight daysrange">
  <label for="CollectionType" class="col-3 form-label"><b class="dayrange">Day range</b></label>
  <br/>
  <input type="text" class="col-2 form-control" id="dayrange" disabled readonly>
</div>

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

0

You didn't mention any errors you've got. You may try this code:

const responses = [
  { CollectionFirstDate: '2021-12-15', StartDay: 1, EndDay: 6 },
];

document.addEventListener('DOMContentLoaded', () => {
  responses.forEach((response) => {
    document.getElementById('DateoffirstcollectionDisplay').value =
      response.CollectionFirstDate;
    document.getElementById(
      'dayrange'
    ).value = `${response.StartDay} - ${response.EndDay}`;
  });
});
<div class="mb-3 StyleFormRestRight dateoffirstcollection">
  <label for="CollectionType" class="col-3 form-label"
    ><b class="Dateoffirstcollection">Date of first collection</b></label
  >
  <br />
  <input
    type="text"
    class="col-2 form-control"
    id="DateoffirstcollectionDisplay"
    disabled
    readonly
  />
</div>

<div class="mb-3 StyleFormRestRight daysrange">
  <label for="CollectionType" class="col-3 form-label"
    ><b class="dayrange">Day range</b></label
  >
  <br />
  <input
    type="text"
    class="col-2 form-control"
    id="dayrange"
    disabled
    readonly
  />
</div>

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