Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
¿Cómo puedo hacer que mi formulario HTML tenga un evento onsubmit y una acción onclick para su botón de envío?

Así que actualmente tengo el siguiente formulario HTML:

 <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>

Aquí está la función sample() :

 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); }); }

Aquí está la función addExpense() :

 function addExpense() { clothingID={'id':Date.now(),'activityType':activityType.value, 'place': place.value, 'amnt':amnt.value, }; leisureArray.push(clothingID); arrayLength++; showTotalBalance(); showDifference(); expenseHistory(); setItemInStorage(); }

La función sample() parece estar anulando la función addExpense() . ¿Cómo puedo solucionar esto?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!