Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda