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

65
Views
Compruebe si se ha introducido el mismo texto dos veces o más

Estoy practicando JavaScript con la biblioteca jQuery.
Lo que quiero es crear algo como una aplicación POS , pero hay cosas que simplemente no puedo entender.
Me gustaría, si ingresa lays , y luego ingresa lays nuevamente, la salida debería cambiar a la salida ya adjunta a lays * 2 .
Estoy un poco perdido sobre cómo lograr lo deseado.
Lo que tengo hasta ahora:

 var billoutput = document.getElementById('inputterminal'); var counter = 1; $('#bill').click(function() { $("#holder").append(" <span style='padding:10px; margin:5px; color:white; background-color:black; border-radius: 10px;'> " + billoutput.value + " </span> "); });
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <h1>POS Terminal</h1> <input id="inputterminal" value="" name="" type="text"> <button id="bill">bill</button> <br> <div style="margin-top: 20px;" id="holder"></div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede almacenar las entradas en una matriz y verificar si la matriz incluye el valor de la entrada cada vez que el usuario hace clic en el botón. Si no es así, agregue el elemento y envíe el valor de la entrada a la matriz.

 var billoutput = document.getElementById('inputterminal'); var counter = 1; var words = [] $('#bill').click(function() { if (!words.includes(billoutput.value)) { words.push(billoutput.value) $("#holder").append(" <span style='padding:10px; margin:5px; color:white; background-color:black; border-radius: 10px;'> " + billoutput.value + " </span> "); }else{ alert("you already entered that!") } })
 <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <h1>POS Terminal</h1> <input id="inputterminal" value="" name="" type="text"> <button id="bill">bill</button> <br> <div style="margin-top: 20px;" id="holder"></div>

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!