So I currently have the following HTML form:
<form id = "leisureExpenses" id = "leisureExpenses" style = "display:none" onsubmit='addExpense();'>
<div class="row">
<div>
<label>Clothing type</label>
<input name = "Activity" id = 'activity' style = "width: 24%;" type="text" placeholder="Enter the clothing type" id="exampleEmailInput">
</div>
</div>
<div>
<div>
<label style = 'padding-bottom: 1pt;' for="exampleEmailInput">Clothing place</label>
<input name = "Place" id="place" style = "width: 24%;" type="text" placeholder="Enter the clothing place" id="exampleEmailInput">
</div>
<label>Amount</label>
<input name = "Amount" id="amnt" style = "width: 24%;" type="number" placeholder="Enter number" id="exampleEmailInput">
</div>
<button type = 'submit' class="button-primary" onclick= "sample(this);return false;">Add expense</button>
<button type = 'button' class="button-primary" onclick="closeExpenseForm()">Close Form</button>
</form>
Here is the sample() function:
function sample(e) {
const url = "https://script.google.com/macros/s/AKfycbw6tJQIK0izFU-Ehb4FF2rpct_fyqvqHDlIiv13eumC18y2Ds0HhNRtAHkiww1A/exec"
const obj = [...e.parentNode].reduce((o, f) => (o[f.name] = f.value, o), {});
const query = new URLSearchParams(obj);
fetch(url + "?" + query, { method: "POST" })
.then((res) => res.json())
.then((res) => {
console.log(res);
alert(res.result);
});
}
Here is the addExpense() function:
function addExpense()
{
clothingID={'id':Date.now(),'activityType':activityType.value, 'place': place.value, 'amnt':amnt.value, };
leisureArray.push(clothingID);
arrayLength++;
showTotalBalance();
showDifference();
expenseHistory();
setItemInStorage();
}
The sample() function seems to be overriding the addExpense() function. How do I fix this?