0

「発効日」と「有効期限」の 2 つの入力テキスト フィールドがあります。jquerytool の dateinput 関数を日付ピッカーとして使用しています。

質問: 「発効日」を選択した場合、「有効期限」を「発効日」から 1 年後に指定し、その値を「有効期限」テキスト入力フィールドに設定したいと思います。

これをすべて機能させることはできないようです...

<script>

$(document).ready(function() {

  $(":date").dateinput({
    format: 'mmmm dd, yyyy', // the format for example: 'October 04, 2012'
  });

function expiration (){
  // date calculations here?...
  ...
  document.getElementById('expiration').value = expirationDate;

}
</script>


<input type="date" name="effective" id="effective" onChange="expiration()" />

<input type="date" name="expiration" id="expiration" />
4

1 に答える 1

0
<script>

function expiration (){
  // date calculations here...
  var effectiveDate = document.getElementById('effective').value;

  var expirationDate = new Date(effectiveDate);

  expirationDate.setDate(expirationDate.getDate()+365);

  document.getElementById('expiration').value = expirationDate;

}
</script>
于 2012-10-04T19:29:15.840 に答える