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

153
Vistas
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 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