HTML
xxxxxxxxxx
1
2
<div class="col-md-6 col-12">
3
<div>
4
<select name="frequencyType" id="frequencyType" class="mdb-select md-form">
5
<option value="">Please select</option>
6
<option value="w" >Once a week</option>
7
<option value="m" >Once a month</option>
8
<option value="x" >Every 3 months</option>
9
<option value="z" >Every 6 months</option>
10
<option value="y" >Once a year</option>
11
</select>
12
<label for="frequencyType" class="mdb-main-label">Frequency:</label>
13
</div>
14
<div>
15
<select name="frequencyAmount_w" id="frequencyAmount_w" class="mdb-select md-form" title=" ">
16
<option value="">Please select</option>
17
<option value="1" >Sun</option>
18
<option value="2" >Mon</option>
19
<option value="3" >Tue</option>
20
<option value="4" >Wed</option>
21
<option value="5" >Thu</option>
22
<option value="6" >Fri</option>
23
<option value="7" >Sat</option>
24
</select>
25
</div>
26
<div>
27
<select name="frequencyAmount_m" id="frequencyAmount_m" class="mdb-select md-form" title=" ">
28
<option value="">Please select</option>
29
<option value="1" >On day 1 of each month</option>
30
<option value="2" >On day 2 of each month</option>
31
<option value="3" >On day 3 of each month</option>
32
<option value="4" >On day 4 of each month</option>
33
<option value="5" >On day 5 of each month</option>
34
<option value="6" >On day 6 of each month</option>
35
<option value="7" >On day 7 of each month</option>
36
<option value="8" >On day 8 of each month</option>
37
<option value="9" >On day 9 of each month</option>
38
<option value="10" >On day 10 of each month</option>
39
<option value="11" >On day 11 of each month</option>
40
<option value="12" >On day 12 of each month</option>
41
<option value="13" >On day 13 of each month</option>
42
<option value="14" >On day 14 of each month</option>
43
<option value="15" >On day 15 of each month</option>
44
<option value="16" >On day 16 of each month</option>
45
<option value="17" >On day 17 of each month</option>
46
<option value="18" >On day 18 of each month</option>
47
<option value="19" >On day 19 of each month</option>
48
<option value="20" >On day 20 of each month</option>
49
<option value="21" >On day 21 of each month</option>
50
<option value="22" >On day 22 of each month</option>
51
<option value="23" >On day 23 of each month</option>
52
<option value="24" >On day 24 of each month</option>
53
<option value="25" >On day 25 of each month</option>
54
<option value="26" >On day 26 of each month</option>
55
<option value="27" >On day 27 of each month</option>
56
<option value="28" >On day 28 of each month</option>
57
<option value="29" >On day 29 of each month</option>
58
<option value="30" >On day 30 of each month</option>
59
<option value="31" >On day 31 of each month</option>
60
</select>
61
</div>
62
<div>
63
<div class="md-form input-with-post-icon datepicker " id="frequencyDateHolder">
64
<input type="text" class="form-control" name="frequencyDate" id="frequencyDate" placeholder="Choose date">
65
<label for="example">Try me...</label>
66
<i class="fas fa-calendar input-prefix"></i>
67
</div>
68
</div>
69
</div>
CSS
xxxxxxxxxx
1
/*#frequencyAmount_m,
2
#frequencyAmount_w, */
3
#frequencyDateHolder { display: none;}
4
JS
xxxxxxxxxx
1
$(document).ready(function() {
2
$("#frequencyType").materialSelect();
3
4
5
$("#frequencyType").change(function(){
6
var frequencyType = $("#frequencyType option:selected").val();
7
8
if (frequencyType=='w') {
9
$("#frequencyAmount_m").hide().materialSelect({destroy: true});
10
$("#frequencyDateHolder").hide();
11
$("#frequencyAmount_w").show().addClass("mdb-select").materialSelect(); //.show().addClass("required");
12
13
} else if (frequencyType =='m') {
14
$("#frequencyAmount_w").hide().materialSelect({destroy: true});
15
$("#frequencyDateHolder").hide();
16
$("#frequencyAmount_m").show().addClass("mdb-select").materialSelect(); //.show().addClass("required");
17
18
} else if (frequencyType =='y') {
19
$("#frequencyAmount_w, #frequencyAmount_m").hide().materialSelect({destroy: true});
20
$("#frequencyDateHolder").show();
21
$("#frequencyDateHolder").datepicker();
22
$('#frequencyDate').on('click', () => {
23
$('i').trigger('click')
24
});
25
26
$("#frequencyDate").addClass("required");
27
28
} else if ( (frequencyType =='z')|| (frequencyType =='x')) {
29
$("#frequencyAmount_w, #frequencyAmount_m").hide().materialSelect({destroy: true});
30
$("#frequencyDateHolder").show();
31
$("#frequencyDateHolder").datepicker();
32
$('#frequencyDate').on('click', () => {
33
$('i').trigger('click')
34
});
35
36
$("#frequencyDate").attr('placeholder','Starting from date').addClass("required");
37
}
38
39
40
41
});
42
43
44
45
});
46
47
Console errors: 0