We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to programmatically select a JavaScript RadioButton?


i know that it is possible to get the value of a selected RadioButton in a group

through the function radiobutton.getSelectedValue(), but how can I SET the

value of RadioButton in a group and check the relative control ?

Maybe does it exists a radiobutton.setSelectedValue(value) function ?

Thank You.


3 Replies

AS Aravinthan Seetharaman Syncfusion Team September 9, 2021 02:18 PM UTC

Thanks for contacting Syncfusion Support. 
We have checked your query. We can achieve your requirement in sample level. Please refer below code snippet. 
let radioButton: RadioButton = new RadioButton({ 
  label: 'Credit/Debit Card', 
  name: 'payment', 
  value: 'credit/debit', 
  checked: true 
radioButton = new RadioButton({ 
  label: 'Net Banking', 
  name: 'payment', 
  value: 'netbanking' 
radioButton = new RadioButton({ 
  label: 'Cash on Delivery', 
  name: 'payment', 
  value: 'cashondelivery' 
radioButton = new RadioButton({ 
  label: 'Other Wallets', 
  name: 'payment', 
  value: 'others' 
document.getElementById('btn').addEventListener('click', function() { 
  var radioGrp = document.getElementsByName('payment'); 
  for (let i = 0; i < radioGrp.length; i++) { 
    let radio = radioGrp[i] as HTMLInputElement; 
    if (radio.value == 'netbanking') { 
      radio.checked = true; 
Could you please check the above details, and get back to us, if you need assistance on this. 
Aravinthan S

AM Alberto Monteverdi September 10, 2021 02:55 AM UTC

Hi Aravinthan,

Yes, it works very well.

Thank You very much.

Kind Regards.

Alberto Monteverdi.

GK Gayathri KarunaiAnandam Syncfusion Team September 10, 2021 05:41 AM UTC

Hi Alberto Monteverdi, 

Thanks for the update. 

We are happy to hear that your requirement has been fulfilled. Please feel free to contact us if you need any further assistance on this. 

Gayathri K 

Live Chat Icon For mobile
Up arrow icon