I am looking for a way to improve the functionality of my web page featuring several buttons that will clear different text boxes on the same line. Currently, I am using separate functions for each button, but my goal is to streamline this process by utilizing a single function that can be customized through passing in the text field ID.
Here is an example of what I have now in HTML:
<div class="col-sm-4">
<input type="text" class="form-control" id="textField1" formControlName="textField1" />
</div>
<button class="btn btn-danger" (click)="clearTextField('textField1')"><i class="fa fa-times"></i></button>
As shown above, I have a specific function for each text field like "clearTextField1()". Is there a way to achieve the desired outcome with just one function and dynamically pass in the text field ID when needed?