Get Value of Hidden Field in Client Side

别来无恙 提交于 2019-12-03 04:59:15

That returns the input. You need the value of the hidden input.

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

Assuming that it's not null you don't use the hiddenfield's value proprty:

var statusFlag = '';
var hiddenStatusFlag = document.getElementById('<%= HiddenStatusFlag.ClientID%>');
if(hiddenStatusFlag != null)
{
    statusFlag = hiddenStatusFlag.value;
}
Ramesh Rajendran

If your hiddenfield used runat="server"

Use this code:

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

else use this code:

StatusFlag = document.getElementById("HiddenStatusFlag").value;

in jquery:

var hiddenValue = $('#hiddenFieldID').val();
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
 <script type="text/javascript" language="javascript">
alert(document.getElementById("<%= Hiddenfield1.ClientID %>").value);
</script>
</head>
<body>

<div>
<asp:hiddenfield ID="Hiddenfield1" runat="server" value="Hussain Testing"></asp:hiddenfield>
</div>
<body>

</html>

in javascript:

var SomeVar = document.getElementById('HiddenField_ID').value;
StatusFlag = SomeVar;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!