N K N K - 5 months ago 14
HTML Question

Assign variable value to hidden field

I am binding a query into the javascript element. like below

StrPriFnName = "FunGetAddInfo1(" + document.getElementById('CmbDocumentType').value + ")";
var ObjPriXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");
ObjPriXMLHTTP.open("GET", "FrmInwardXMLHTTP.aspx?para=" + StrPriFnName, false);
ObjPriXMLHTTP.send("");
var StrStatusXMLHTTP = ObjPriXMLHTTP.responseText;
if (ObjPriXMLHTTP.responseText != "") {
StrPriRow = ObjPriXMLHTTP.responseText.split('|');
for (IntPriI = 0; IntPriI < StrPriRow.length - 1; IntPriI++) {
StrPriCol = StrPriRow[IntPriI].split('~');
var ObjPriOption = document.createElement("hidden");
ObjPriOption.text = StrPriCol[1];
ObjPriOption.value = StrPriCol[0];
document.getElementById('HidEmailId').value = ObjPriOption.value;
}
}
}


but, I am not getting value in
HidEmailId


as my
ObjPriOption.value
contains value.

How to assign the value in the hidden field

Answer

Try

document.getElementById('<%= HidEmailId.ClientID %>').value;

You are using asp.net hidden field whichs ID is changed according to contentplaceholder id