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

152
Views
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
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!