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
close icon

Get radio button value

    Hi

  I need  page load rbyes radio button default checked true and Jquery button click event get radio button status (true/false)

 <table>

<tr> 

<td>

<input type="radio" name="radiobutn" id="rbyes" />

<label for="radiobtn">yes</label>

 </td>

<td>

<input type="radio" name="radiobutn" id="rbno" />

<label for="radiobtn">no</label>

</td>

</tr>

</table>

  Thanks
Pratheep              

1 Reply

SP Sureshkumar P Syncfusion Team May 4, 2017 01:21 PM UTC

Hi Pratheep, 
 
Thanks for contacting Syncfusion support, 
 
Query 1: when page load the radio button default state is checked. 
We have checked with your query and you can achieve your requirement by using our existing “checked” property. please refer the below code example 
 
<ej:RadioButton Name="category" ID="Radio1" runat="server"  
                Checked="true" Text="1+ years" ></ej:RadioButton>        
   
 
 
Query 2: in button click, need to get radio button status (true/false): 
               This can be achieved with help of our existing “checked” property which will return the checked state of the radio button. 
 
Here we have used our EJ button and its click event. In this event, we get the checked state of required radio button by using instance of that required button. 
 
Please refer the below code sample 
[body] 
<ej:RadioButton Name="category" ID="Radio1" runat="server" CssClass="RadioNode" Checked="true" Text="1+ years" ></ej:RadioButton>  
 
<ej:Button ID="btn" runat="server" Type="Button" Text="Status" ClientSideOnClick="onBtnClick"></ej:Button>  
[script] 
function onBtnClick() { // triggers while click the ejbutton 
 
            obj = $("#<%=Radio1.ClientID%>").ejRadioButton("instance"); 
               // instance creation for radiobutton 
             
            console.log("the radioButton checked state is : " + obj.model.checked); 
            // obj.model.checked – prints the checked status of the radiobutton             
        } 
 
In the above code example, we have render the first radiobutton as checked state in initial loading by setting our “checked” property as “true” and while click the ejbutton we have get the radiobutton status by using “checked” property with created instance to the radiobutton.  
 
for your convenience, we have attached the sample in the bellow link http://www.syncfusion.com/downloads/support/forum/130269/ze/RadioButton_forum130269232294174   
 
Please find the documentation link to know more about the “checked” property. Refer to the following link https://help.syncfusion.com/api/js/ejradiobutton#members:checked  
Please let us know if you need any further assistance.  
 
Regards, 
Sureshkumar P 


Loader.
Live Chat Icon For mobile
Up arrow icon