Users can select a medicine for each day of their plan, with the option to choose up to 7 days. I want to dynamically show a corresponding number of Select dropdowns based on the user's selection.
body {
width: 500px;
margin: 0 auto;
padding: 50px;
}
div.elem-group {
margin: 20px 0;
}
div.elem-group.inlined {
width: 49%;
display: inline-block;
float: left;
margin-left: 1%;
}
label {
display: block;
font-family: 'Nanum Gothic';
padding-bottom: 10px;
font-size: 1.25em;
}
input, select, textarea {
border-radius: 2px;
border: 2px solid #777;
box-sizing: border-box;
font-size: 1.25em;
font-family: 'Nanum Gothic';
width: 100%;
padding: 10px;
}
div.elem-group.inlined input {
width: 95%;
display: inline-block;
}
textarea {
height: 250px;
}
hr {
border: 1px dotted #ccc;
}
button {
height: 50px;
background: orange;
border: none;
color: white;
font-size: 1.25em;
font-family: 'Nanum Gothic';
border-radius: 4px;
cursor: pointer;
}
button:hover {
border: 2px solid black;
}
.btn-fetch{
width: 120%;
padding: 14px 20px;
margin: 8px 5px;
border: none;
border-radius: 4px;
cursor: pointer;
background-color: #3498DB;
color: white;
}
<form #datesForm = "ngForm" (ngSubmit)="checkDates(datesForm.value)">
<div class="elem-group inlined">
<label>First Day Of Your Plan</label>
<input type="date" name="firstDate" required>
</div>
<div class="elem-group inlined">
<label>Last Day Of Your Plan</label>
<input type="date" name="lastDate" required>
</div>
<button class="btn-fetch" (click)="checkDates(datesForm.value)">Confirm Dates</button>
<div class="elem-group" >
<label>Select A Plan Number </label>
<select name="planId" id="deviceoption" (click)="fetchPlans()" required>
<option type=placeholder>Choose a number from the List</option>
</select>
<br><br>
<select name="meds" required>
<option value="">Choose a Medicine</option>
<option value="medsName"></option>
</select>
</div>
<button type="submit">Save the Plan</button>
</form>
If a user selects 5 days, there will be 5 instances of the "Choose Medicine" option, and if they select 7 days, there will be 7 instances. Any advice on how to achieve this dynamic functionality?