why do i lose my hidden field value?
Posted
by
user517406
on Stack Overflow
See other posts from Stack Overflow
or by user517406
Published on 2011-02-25T15:18:20Z
Indexed on
2011/02/25
15:25 UTC
Read the original article
Hit count: 236
JavaScript
|jQuery
Hi,
I have some hidden fields on my page, all of which work fine apart from one. I am setting the value in document.ready, before calling buildGrid() :
$(document).ready(function() {
$.ajax(
{
type: "POST",
url: "/CDServices.asmx/GetWeekEndingDates",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(msg) {
//store default dates in hidden fields
$("#<%=hdnCurrentDate.ClientID%>").val(msg.d.CurrentDate);
$("#<%=hdnLastWeekEndingDate.ClientID%>").val(msg.d.LastWeekEndingDate);
}
});
buildGrid();
});
Yet in buildGrid, the value in the hidden field is empty :
function buildGrid() {
alert($("#<%=hdnLastWeekEndingDate.ClientID%>").val());
I call other functions on button clicks where the hidden field value is picked up fine, why does the value disappear here?
© Stack Overflow or respective owner