Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Auto Increment in js with custom prefix

I need to generate a username with prefix start from 00000,so first user should be MS00001 and if reach 100,000 user will be MS100000.

the lastcustomers is query

SELECT * FROM customers WHERE id=(SELECT max(id) FROM customers)

My first idea is to query from my database and get the user id which have auto increment in mysql.

and +1 base on the return id in my input.

<% if(customers=="" ){ %>
      <div class="form-group">
              <label for="addMemberUsername">UserName</label>
               <input value="MS00001" type="text" class="form-control"
                name="addMemberUsername" placeholder="Username">
      </div>
 <% }else { %>
        <div class="form-group">
                <label for="addMemberUsername">UserName</label>
                <input value="MS0000<%= LastCustomers[0].id + 1 %>" type="text"
                 class="form-control" name="addMemberUsername"
                 placeholder="Username">
                 </div>
<% } %>

but this hard code cant change the 10th record to become MS000010, how I make it to MS00010 and if reach 100,000 user will be MS100000.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda