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

163
Visualizações
How to set radio button value as checked or unchecked situation
<input type="radio" name="imgsel"  value="" checked />

My requirement is : This radio button by default checked then value of this button is 'present'. When this button is unchecked , then value this button is 'absent'. how can i do this?

please, help me . Thanks in advance .

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

0

function valChange(element)
{
   if (element.checked)
  {
     alert("present");
  } else
  {
    alert("absent");
  }
   }
<input id="button" type="checkbox" name="imgsel" 
onchange="valChange(this)" value="" checked />

about 4 years ago · Juan Pablo Isaza Relatório

0

The following example replaces the value of the checkbox when clicked. First the click event must be bound to the checkbox. The EventHandler checks whether the box has already been checked. If not, it checks it and sets the value in the checkbox. And if it has not been checked, the other way round.

let i = document.querySelector('input');

i.addEventListener('click', (ev) => {
  let el = ev.target;
  
  if (el.getAttribute('checked') === null) {
    el.setAttribute('checked', true);
    el.value = "present"         
  } else {    
    el.removeAttribute('checked');
    el.value = "absent"    
  }
  let checkValue = document.querySelector('input').value
  alert(checkValue)
})
<input type="radio" name="imgsel"  value="" checked />

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