js动态获取文本框的值 js获取月份的天数...
时间:2010-08-14 来源:shanshan209
<script type="text/javascript" language="javascript">
function txtChange()
{
var time=document.getElementById("txtWorkTime").value;
var days=document.getElementById("txtWorkDays").value;
var rate=document.getElementById("txtRate").value;
var extraTime=document.getElementById("txtExtraTime").value;
if(time=="" ||days==""||rate=="")
{
if(extraTime=="")
{
document.getElementById("txtTotalTime").value="0";
}
else
{
document.getElementById("txtTotalTime").value= extraTime;
}
}
else if(extraTime!="")
{
var totalTime=(time*days*rate*0.01)+parseInt(extraTime);
document.getElementById("txtTotalTime").value= totalTime;
}
else
{
var totalTime=(time*days*rate*0.01);
document.getElementById("txtTotalTime").value= totalTime;
}
}
function days()
{
var year= document.getElementById("txtYearMonth").value;
var month=year.substr(5,2);
year=year.substr(0,4);
var days=new Date(year,month,0).getDate();
document.getElementById("txtWorkDays").value=days;
}
</script>
<asp:TextBox ID="txtYearMonth" runat="server" onpropertychange="days();"></asp:TextBox>
<br />
<asp:TextBox ID="txtWorkTime" runat="server" OnTextChanged="txtWorkTime_TextChanged" onpropertychange="txtChange();">