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

150
Views
¿Cómo puedo llamar a la función seleccionada la cantidad de veces?

Estoy tratando de ejecutar la función getOrderData la cantidad de veces que el usuario seleccionó en el menú desplegable, ¿cómo puedo hacer eso?

Archivo de jade:

 p strong Number of pieces: select(id='numOfPieces')

Archivo Javascript:

 function getOrderData() { //this just creates the dropdown dynamically so I could get number that user selected by index value const dropdown = document.getElementById("numOfPieces"); var options = ["1", "2", "3", "4", "5"]; for(var i = 0; i < options.length; i++) { var opt = options[i]; var el = document.createElement("option"); el.textContent = opt; el.value = opt; dropdown.appendChild(el); } //checks selected number let times = dropdown.options[dropdown.selectedIndex].value; } $("#yes").click(function () { getOrderData(); }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

function getOrderData() { alert('Hallo!!'); } $("#yes").click(function () { let value = $('#numOfPieces').val(); value = value && value>0 ? parseInt(value) : 1; for (let i = 0; i < value; i++) { getOrderData(); } });
about 4 years ago · Juan Pablo Isaza Report

0

Puede usar el método times() a partir de 30 segundos de código . Aquí está el código de ese sitio web, además de un ejemplo:

 const times = (n, fn, context = undefined) => { let i = 0; while (fn.call(context, i) !== false && ++i < n) {} }; times(5, i => console.log(`Called ${ i } times.`));

about 4 years ago · Juan Pablo Isaza Report
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!