js 第二次选择时清空select option 50
代码如下,当选择付款周期时,合同结束日期会根据付款周期自动在合同开始日期上加上付款周期,现在问题是可以实现了,但是,当更改的时候,结束日期会在第一次选择的日期上继续增加。...
代码如下,当选择付款周期时,合同结束日期会根据付款周期自动在合同开始日期上加上付款周期,现在问题是可以实现了,但是,当更改的时候,结束日期会在第一次选择的日期上继续增加。举个例子,第一次选择年付,结束日期是2019-1-19,再更改为半年付,结束日期又成了2019-6-19,而不是2018-6-19。麻烦大神看一下JS代码,怎样修改一下。<tr> <td height="40" align="right">付款周期:</td> <td> <select name="fukuanzhouqi" id="fukuanzhouqi" class="input"> <option value="0" selected="selected">请选择付款周期</option> <?php GetSelectSec('#@__fukuanzhouqi'); ?> </select><span class="maroon">*</span> </td></tr><tr> <td height="40" align="right">第1次合同<span style="color:#F00">起始日期</span>:</td> <td><input name="hetongstart" type="text" id="hetongstart" class="inputms" value="<?php echo GetDateMk(time()); ?>" /><span class="maroon">*</span> <script type="text/javascript"> date = new Date(); Calendar.setup({ inputField : "hetongstart", ifFormat : "%Y-%m-%d", showsTime : false }); </script> </td> </tr> <tr> <td height="40" align="right">第1次合同<span style="color:#F00">终止日期</span>:</td> <td><input name="hetongfinish" type="text" id="hetongfinish" class="inputms" /><span class="maroon">*</span> </td> </tr><script> var valuea=document.getElementById("hetongstart").value; var d=new Date(valuea); $(document).ready(function(){ $("#fukuanzhouqi").change(function(){ var value2 = document.getElementById("fukuanzhouqi").value; if(value2 == 1) { $("#hetongfinish").empty(); d.setMonth(d.getMonth()+11); var str1 = d.getFullYear()+"-"+(d.getMonth()>=9?d.getMonth()+1:"0"+(d.getMonth()+1))+"-"+(d.getDate()>9?d.getDate():"0"+d.getDate()); document.getElementById("hetongfinish").value=str1; } else if(value2 == 2) { $("#hetongfinish").empty(); d.setMonth(d.getMonth()+5); var str2 = d.getFullYear()+"-"+(d.getMonth()>=9?d.getMonth()+1:"0"+(d.getMonth()+1))+"-"+(d.getDate()>9?d.getDate():"0"+d.getDate()); document.getElementById("hetongfinish").value=str2; } else if(value2 == 3) { d.setMonth(d.getMonth()+2); var str3 = d.getFullYear()+"-"+(d.getMonth()>=9?d.getMonth()+1:"0"+(d.getMonth()+1))+"-"+(d.getDate()>9?d.getDate():"0"+d.getDate()); document.getElementById("hetongfinish").value=str3; } else if(value2 == 4) { d.setDate(d.getDate()+30); var str = d.getFullYear()+"-"+(d.getMonth()>=9?d.getMonth()+1:"0"+(d.getMonth()+1))+"-"+(d.getDate()>9?d.getDate():"0"+d.getDate()); document.getElementById("hetongfinish").value=str; } else{ d.setDate(d.getDate()); } }); }); </script>
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询