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 set a default value to radio button so that it is checked

how to set a default value to radio button so that it is checked and also on change of radio button i need to get the value of radio button selected
for example if i have a radio buttons
1.net banking 
2.debit card 
3.cash

by default debit card must be checked and also on change of debit card to net banking i need to get the value of selected item (i.e)net banking

Thanks in Advance
Regards 
Thowbik

3 Replies

VK Vinoth Kumar Sundara Moorthy Syncfusion Team May 6, 2019 01:30 PM UTC

Hi Thowfik, 
 
Thank you for contacting Syncfusion support. 
 
We have checked your reported requirement “To set the default value and get the selected value in radiobutton” and it can be achieved in our EJ2 RadioButton using “checked” property and getSelectedValue method as like as below.  
 
Code example 
<ejs-radiobutton label="Net Banking" name="payment" value="netbanking" checked="true">ejs-radiobutton> 
 
btnClick(){ 
    alert(this.radioButton.getSelectedValue()); // To get the selected value 
} 
 
For your convenience, we have prepared the sample based on your requirement. Please find the link below. 
 
 
Could you please check the above sample and get back to us, if you need any further assistance on this? 
 
Regards, 
Vinoth Kumar S 



TH thowfik May 9, 2019 06:22 AM UTC

instead of onclick i need to get the selected value on change of radio button.

Thanks in advance

Regards
Thowbik


VK Vinoth Kumar Sundara Moorthy Syncfusion Team May 9, 2019 10:35 AM UTC

Hi Thowbik, 
 
Good day to you. 
 
We have modified the previously updated sample to achieve your requirement “To get the changed value in RadioButton” using RadioButton change event as like in the below code example, 
 
[HTML
<ejs-radiobutton #radiobutton label="Credit/Debit card" name="payment" value="credit/debit" (change)=onchange($event)></ejs-radiobutton> 
 
[TS
onchange(args){ 
    //To get the changed value 
    alert(args.value); 
} 
 
 
Could you please check the above sample and get back to us if you need any further assistance on this? 
 
Regards, 
Vinoth Kumar S 


Loader.
Live Chat Icon For mobile
Up arrow icon