Open harrymohney opened 1 year ago
Inside your new form you might want to consider using a for loop to iterate over a range
assuming you have a set range context variables (rangeStart, rangeStop, weightIncrement) you could write an EJS iterator like
<select name="weight" ...rest of your attributes here>
<!-- your default value -->
<% for (let weight= rangeStart; weight<=rangeStop; weight+=weightIncrement){ %>
<option value="<%=weight%>"><%=weight%>lbs</option>
<%}%>
</select>
Any time you find yourself writing a lot of repetitive code you might have an opportunity to stop, step back, and study the problem more carefully, looking for optimizations.
Additionally, with this dynamic approach you could create just one page that changes the content depending on the state of your model data. Or dynamically change your weight ranges depending on the selected drop down type using client side DOM manipulation (TTT team might be able to help you out with that approach!)
Over all, a great candidate for a refactor - good luck!
Consolidation of our 7 'new_...ejs' files into a more efficient code body with less code and same options.