从ddlCountryName下拉菜单中,我想获取hdnCountryCode中的值
function getWorkCenter() {
debugger;
var SelectedCountryCode = $('#ddlCountryName').val();
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "FocussedMktBenefit.aspx/GetWorkCenter",
data: '{"sPlant":"' + SelectedCountryCode + '"}',
dataType: "json",
success: function (data) {
var jsonProcessDetails = jQuery.parseJSON(JSON.stringify(data.d));
},
error: function (Result) {
alert("Error with AJAX callback");
}
});
}
数据也来自使用FocussedMktBenefit.aspx / GetWorkCenter的.cs页面,但是如何获取隐藏字段是个问题。
答案 0 :(得分:0)
<select id="hdnCountryCode" style="display:none;">
<option value="123">aaa</option>
<option value="456">bbb</option>
</select>
你是这个意思吗?
答案 1 :(得分:0)
我猜你想做这样的事情。
var jsonProcessDetails = jQuery.parseJSON(JSON.stringify(data.d));
$("hdnCountryCode").val(jsonProcessDetails);
或者,如果您位于aspx页面上,并且“隐藏”字段为runat="server"
,那么
var jsonProcessDetails = jQuery.parseJSON(JSON.stringify(data.d));
$("[id$=hdnCountryCode]").val(jsonProcessDetails);