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

154
Visualizações
replace UI in a button click while UI is generated by PHP in advance

I have a block of html code that's being generated by PHP function that's executed using an ajax request, and I want to add to this html a toggle button that will change several fields in the this block of UI (and also the text inside the button itself).

My idea was to create the new fields within the same PHP function but with display=none and have a css class to the fields e.g .new to all of the new fields and .old to the old fields that shouldn't appear, then hide all of the .old fields and display the new ones (and vise versa) using JS function when the button is clicked.

another approach is to build another similar PHP function to build the new UI (even though most of the elements are similar) and the new button will have an onclick function that makes an ajax call to run the corresponding PHP function.

I'm not sure which is the right approach in this case, or is there a simpler/better solution.

would appreciate any feedback. if any additional info is needed let me know.

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