0
月と年を含む3つの選択ボックスがあります。今年を選択すると、前の月を月選択ボックスから削除します。来年または他の年を選択すると、すべての月が表示されます。私は多くの方法をチェックしましたが、正しく動作しませんでした。オプションを選択して今月から月を削除します
他の年を選択すると、現在の年に期限が切れているすべてのインデックスまたは月を削除し、すべての月を表示する方法を教えてください。
<select name="date">
<option value="0">Day</option>
<option value="2">1</option>
<option value="3">1</option>
<option value="4">1</option>
..
<option value="31">31</option>
</select>
<select name="month">
<option value="0">Month</option>
<option value="jan">January</option>
<option value="feb">February</option>
<option value="mar">March</option>
..
<option value="dec">December</option>
</select>
<select name="year">
<option value="0">Year</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
...
<option value="2030">2030</option>
</select>
ロジックは今のようになります。
$(".year").on('change', function() {
//get the current year
if selected year is current year -> I got this right
then remove expired months -> This is not working right
if selected year is others -> Selected month should remain there
then show all the months
});
私たちに教えるhtml code mate – rahulsm