Hi. I’m trying to take the user input and add it to the database. I keep getting 2 submissions - one containing the user input and the other is blank.
How to remove the blank spaces?
Here’s my code -
export function button1_click(event) {
wixData.query("items")
.eq("itemName", $w('#dropdown1').value)
.find()
.then((results) => {
console.log(results)
bill_amt = results.items[0].itemPrice;
console.log(bill_amt)
let toSave = {
"patientName": $w('#input1').value,
"phoneNumber": Number($w('#input2').value),
"newBill": $w('#dropdown1').value,
"newBillPrice": bill_amt,
};
wixData.save("patientrecords", toSave)
.then( (results1) => {
console.log("Saved")
$w('#text20').expand()
setTimeout(() => $w('#text20').collapse(), 2000)
console.log(results1)
} )
.catch( (err) => {
let errorMsg = err;
setTimeout(() => $w('#text21').collapse(), 2000)
$w('#text21').text = err;
} );
Here’s the image of the database where you can see empty rows in between each submission.