Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda