js点击select触发onchange函数

点击select 中的不同option,生效日期框填入不同的日期:

<table width="800" border="0">
        <tr> 
          <td width="180" class="LABEL">状态:</td>
          <td width="140" > 	
            <select name="status" id="PDStatus"  onchange="changeEffDate(this.options[this.options.selectedIndex].value)">
				<option value="0"  selected  > </option>
                <option value="1" > 未申请 </option>
                <option value="2" > 申请通过</option>
                <option value="3" > 已撤销 </option>
            </select>
          </td>
          <td width="120" class="LABEL">生效日期:</td>
          <td width="134"> 
            <input type="text" name="effectiveDate" id="effectiveDate" maxlength="10" size="12"  value="">
          </td>
          <td width="140" class="LABEL">&nbsp;</td>
          <td width="120"> &nbsp;
          </td>
        </tr>
      </table>

script函数:

function changeEffDate(num){
	var Termdte = "";//yyyy/MM/dd
	var dateNow = getNowFormatDate();
	if("1"==num) document.getElementById("effectiveDate").value =Termdte;
	if("23".indexOf(num)>=0) document.getElementById("effectiveDate").value =dateNow;
	if("0"==num)document.getElementById("effectiveDate").value="";
} 
原文地址:https://www.cnblogs.com/DiZhang/p/12544887.html