Asp.Net

Adding days which we have to get from a textbox and add to the current date and store the result in another text box using javascript

Asp.net  textboxes:

<asp:TextBox ID="txtTerms" runat="server" SkinID="CMS_Std_Txtbox" Width="34px" MaxLength="10" onchange="javascript:show()"></asp:TextBox>

<asp:TextBox ID="txtPaymentDueDate" runat="server" BackColor="#E0E0E0" ReadOnly="True"SkinID="CMS_Std_Txtboxcolor" Width="85px" Enabled="False"></asp:TextBox>

Javascript:

<script type="text/javascript">
function show()
{
var currentDate = new Date();
var terms =document.getElementById('<%=txtTerms.ClientID %>').value;
terms=parseInt(terms);
 //adding days what is there in the terms textbox
currentDate.setDate(currentDate.getDate()+ terms);
var dd=currentDate.getDate();
var mm=currentDate.getMonth()+1;
var yyyy=currentDate.getFullYear();
var currentDate=dd+'-'+mm+'-'+yyyy;
document.getElementById('<%=txtPaymentDueDate.ClientID %>').value=currentDate;
}
</script>



No comments:

Post a Comment