Click here to Skip to main content
16,015,481 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am inserting radio button value like (0 or 1) in database.but in my edit page i am not getting the value.it showing undefined
Here is my insert code.
</td>
                                   <td align="center">

                                       <label style="color:red"> @Html.RadioButtonFor(x => x.H_TO_V_Y_CITATION, 0, new { @class = "form-control", @checked = "checked" }) On The Line</label>
                                   </td>
                                   <td align="center">
                                       <label> @Html.RadioButtonFor(x => x.H_TO_V_Y_CITATION, 1, new { @class = "form-control" })Superscript</label>

                                   </td>

// here is my edit page to fetch the data..
$('#DataFetch').click(function () {


            if ($('#ddlCode').val() == "" || $('#ddlType').val() == "" || $('#ddlName').val() == "") {
                debugger;
                alert("Please select appropriate value");
                window.location.href = "/StyleCreator/EditHarvardToVancover";
            }

            else {

               
                $.ajax({
                    url: '/StyleCreator/getHar_To_Van',
                    dataType: "json",
                    async: false,
                    contentType: "application/json;charset=UTF-8",
                    data: { Type: $('#ddlType').val(), Name: $('#ddlName').val(), Code: $('#ddlCode').val() },
                    success: function (data) {

                        $('#t1').html($('#ddlType').val())
                        $('#t2').html($('#ddlName').val())
                        $('#t3').html($('#ddlCode').val())
                        debugger;
                        //var x = $(document).find()

                        $("input[name='H_TO_V_G_CITATION'][value='" + data.H_TO_V_G_CITATION + "']").attr('checked', true) // these are also radio button,i am getting this value
                        $("input[name='H_TO_V_R_CITATION'][value='" + data.H_TO_V_R_CITATION + "']").attr('checked', true)// these are also radio button,i am getting this value

                        $("input[name='H_TO_V_Y_CITATION'][value='" + data.H_TO_V_Y_CITATION + "']").attr('checked', true) // but for this it shows undefined 
                       
                        /

                     


                    },
                    error: function () {
                        alert("error");
                    }


                })
            }


        })


What I have tried:

$("input[name='H_TO_V_G_CITATION'][value='" + data.H_TO_V_G_CITATION + "']").attr('checked', true)
Posted
Comments
Richard Deeming 28-Apr-17 7:48am    
What precisely is showing as "undefined"?

If it's data.H_TO_V_Y_CITATION, then there's a problem with your getHar_To_Van action, which you haven't shown.
Member 13054945 2-May-17 5:33am    
Thank you so much.
Member 13054945 2-May-17 5:35am    
I got the error.now its working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900