I need to dynamically add fields to a form page so users can add additional entries of the same form. It's a form to describe units in a subdivision, and the number of units and types vary. I need to add like a plus button using js that will allow them to add fields, and for those field names to be incremented I guess so they are all separate inputs into the handler. What i have for html is as follows
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="exhibitb.css" rel="stylesheet">
<meta charset="utf-8">
<title>Chicago Low-Income Housing Trust Fund</title>
</head>
<body>
<form action="/clihtf.php" method="post">
<div class="bold2"> Exhibit B</div>
<div class="bold"> DSU</div>
<section>
<p>
<span>unit: </span>
<br>
</label>
<input type="number" id="totUni" name="totUni" >
<p>
<label for="nbr">
<span>nbr: </span>
</label>
<br>
<input type="number" id="nbr" name="nbr" >
</p>
<p>
<label for="trsu">
<span>trsu: </span>
</label>
<br>
<input type="number" id="trsu" name="trsu">
</p>
<p>
<label for="mtpr">
<span>Mtpr: </span>
</label>
<br>
<input type="text" id="mtpr" name="mtpr">
</p>
<p>
<label for="msasu">
<span>Monthly SAU: </span>
</label>
<br>
<input type="text" id="msasu" name="msasu">
<p>
<label for="ssfga">
<span>Social SOP (Exhibit F):
<br> </span>
</label>
<br>
<input type="text" id="ssfga" name="ssfga">
<p>
<label for="ssfgb">
Social Service Plan (Exhibit G):
<br>
<input type="text" id="ssfgb" name="ssfgb">
<p> <button type="submit" value="submit">Submit</button> </p>
</form>
</body>
I have tried what is shown here: Adding input fields in Javascript with onclick button and How to create a minus and plus button to update a field? but I'm just not getting it. I just need to literally duplicate all the fields and then have them be submit with separate names. If this is asking too much, I am sorry.