我无法从数据库中获取单选按钮值 [英] I am not able to fetch radio button value from database
本文介绍了我无法从数据库中获取单选按钮值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据库中插入单选按钮值,如(0或1)。但在我的编辑页面中,我没有得到value.it显示 undefined
这是我的插入代码。
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)
推荐答案
('#DataFetch')。click(function(){
if(
('#DataFetch').click(function () { if (
('#ddlCode ').val()==||
('#ddlCode').val() == "" ||
('#ddlType')。val()==||
('#ddlType').val() == "" ||
这篇关于我无法从数据库中获取单选按钮值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文