Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!