Get values from RadioButton

4 posts, 1 answers
  1. Ram
    Ram avatar
    5 posts
    Member since:
    Nov 2016

    Posted 07 Feb Link to this post

    Hi all

    I saw this demo  :  http://demos.telerik.com/aspnet-mvc/styling/radios

    I want to know which radiobutton that user checked in client side.

    for this one

    @(Html.Kendo().RadioButton().Name("engine1").Checked(true).HtmlAttributes(new{@name = "engine"}).Label("1.4 Petrol, 92kW"));

    I'm trying to use this

    var rbEngine = $("#engine1").data("kendoRadioButton");

    but I can't get any value...even checking status...

    Am I using wrong method?  

    Thanks

     

     

     

     

     

  2. Answer
    Eduardo Serra
    Admin
    Eduardo Serra avatar
    90 posts

    Posted 07 Feb Link to this post

    Hello Ram,

    You can try the following:

    if ($("[name='engine1']").is(":checked"))

    I hope this helps!

    Regards,
    Eduardo Serra
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Ram
    Ram avatar
    5 posts
    Member since:
    Nov 2016

    Posted 07 Feb in reply to Eduardo Serra Link to this post

    Hi : Eduardo Serra thank you!
    I get the checked status by using  
    $("[name='engine']").is(":checked")   
    but
    If there are two Radiobuttin existing like this
        @(Html.Kendo().RadioButton().Name("engine1").Checked(true).HtmlAttributes(new { @name = "engine" }).Label("1.4 Petrol, 92kW"));
        @(Html.Kendo().RadioButton().Name("engine2").HtmlAttributes(new { @name = "engine" }).Label("1.8 Petrol, 118kW"));
    always get True value in this situation.

    Finally I'm using     $("[id='engine1_']").is(":checked")
    I don't know where is the '_' char from, in HTML like this
    <input checked="checked" class="k-radio" id="engine1_" name="engine" type="radio" value="">
    <input class="k-radio" id="engine2_" name="engine" type="radio" value="">

    Thank you agin, Eduardo Serra.

  4. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    388 posts

    Posted 09 Feb Link to this post

    Hello Ram,

    I am happy to learn that you have successfully implemented the desired check.

    Normally, the rendered input elements for the Kendo widgets have both the Name and the Id attributes set to the same value. In the discussed scenario, the underscore is automatically appended to the id of the input to signify the fact that the two values are different.

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top