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

218
Visualizações
JavaScript for PDF button to set value for multiple dropdown lists

I'm creating form fillable pdfs that have a lot of drop down lists with the same options: X = OK, D = Defect, N = Not Applicable, and O = Repair Made. A lot of the time everything will be marked OK, so rather than selecting X in each drop down list, it would be great if clicking a button at the top would set the value for each drop down to X.

It would be great if it only marked empty drop downs as OK so if the user already filled out with something other than OK it doesn't overwrite it.

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

0

As far as I understand, you have a bunch of drop down lists with options X, D, N and O. You want a button which will set all unset drop downs to X when clicked.

Below is a "poorly written" code sample for that. You can use it as a starting point.

document.getElementById("okSetBtn").addEventListener("click", function(e) {
    document.querySelectorAll(".status").forEach(a => a.value = a.value || "X");
});
<button id="okSetBtn">Set unset to OK</button>
<div>
  <label>Status 1</label>
  <select class="status" id="status1">
    <option value=""></option>
    <option value="X">OK</option>
    <option value="D">Defect</option>
    <option value="N">Not Applicable</option>
    <option value="O">Repair Made</option>
  </select>
</div>
<div>
  <label>Status 2</label>
  <select class="status" id="status2">
    <option value=""></option>
    <option value="X">OK</option>
    <option value="D">Defect</option>
    <option value="N">Not Applicable</option>
    <option value="O">Repair Made</option>
  </select>
</div>
<div>
  <label>Status 3</label>
  <select class="status" id="status3">
    <option value=""></option>
    <option value="X">OK</option>
    <option value="D">Defect</option>
    <option value="N">Not Applicable</option>
    <option value="O">Repair Made</option>
  </select>
</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