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

152
Visualizações
Javascript to fill definite values only

I am trying to use a JS code to fill up elements with their already filled up values as desribed in the table here

The JS code suggested by some members here which has worked partially is this:

document.querySelectorAll("[id^='1253']")
  .forEach(o => {
    if (o.value) o.value = `(${o.value})`;
  });

Problem is that I need this condition that, if value =>0.9 then also it should NOT do the prepend and append function and leave the value as it is like shown in the table picture above. The code above is filling for all non-blank values (including values=>0.9). Please help me to solve my problem. Regards, Vicky.

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

0

document.querySelectorAll("[id^='1253']")
  .forEach(o => {
    if (o.value && parseFloat(o.value) < 0.9)
      o.value = `(${o.value})`;
  });

just do add another condition parseFloat(o.value) < 0.9 means only the value with below 0.9 will be changed. parseFloat parses the o.value to float so it can be compared to 0.9

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