jquery - javascript input field get cleared when page postback -
i working vb asp.net , end sql in have choose date calendar used javascript calendar client side coding , other controls , when page postback lost calendar value selected have keep date till click save button here textbox input
<input name="txtpodate" id="inputfield00" type="text" style="width:28px; font-family:segoe ui; font-size:14pt; height: 20pt; background-color: #3366ff;" onclick ="a();" />
i have used hidden field , onblur , onfocus events not working,
the calendar function is
<link rel="stylesheet" type="text/css" media="all" href="jsdatepick_ltr.min.css" /> <script type="text/javascript" src="jsdatepick.min.1.3.js" ></script> <script type="text/javascript" id ="calender"> function setcurrentdate() { var d = new date(); var month = new array(); month[0] = "jan"; month[1] = "feb"; month[2] = "mar"; month[3] = "apr"; month[4] = "may"; month[5] = "jun"; month[6] = "jul"; month[7] = "aug"; month[8] = "sep"; month[9] = "oct"; month[10] = "now"; month[11] = "dec"; var mnth = month[d.getmonth()]; var convertedstartdate = new date(); var day = convertedstartdate.getdate(); var year = convertedstartdate.getfullyear(); var shortstartdate = day + "-" + mnth + "-" + year; document.getelementbyid("inputfield00").text = shortstartdate; document.getelementbyid("inputfield").value = shortstartdate; document.getelementbyid("inputfield0").value = shortstartdate; } function a() { new jsdatepick({ usemode: 2, target: "inputfield00", dateformat: "%d-%m-%y" }); new jsdatepick({ usemode: 2, target: "inputfield", dateformat: "%d-%m-%y" }); new jsdatepick({ usemode: 2, target: "inputfield0", dateformat: "%d-%m-%y" }); setcurrentdate(); }; </script> </asp:content>
can me?
modify input tag below add runat=server
<input runat="server" name="txtpodate" id="inputfield00" type="text" style="width:28px; font-family:segoe ui; font-size:14pt; height: 20pt; background-color: #3366ff;" onclick ="a();" />
then edit script new generated clientid input field
in
document.getelementbyid("<%= inputfield00.clientid %>").text = shortstartdate;
and
new jsdatepick({ usemode: 2, target: "<%= inputfield00.clientid %>", dateformat: "%d-%m-%y" });
Comments
Post a Comment