What are some alternative solutions to displaying a form based on a user interaction, instead of using PHP directly?

Issue: Instead of using PHP directly to display a form based on a user interaction, an alternative solution could be to use JavaScript to show or hide the form dynamically without reloading the page.

<!-- HTML code to display a button that triggers the form display -->
<button id="showFormButton">Show Form</button>

<!-- HTML code for the form that is initially hidden -->
<form id="myForm" style="display:none;">
  <!-- Form fields go here -->
</form>

<!-- JavaScript code to show or hide the form based on user interaction -->
<script>
  document.getElementById('showFormButton').addEventListener('click', function() {
    document.getElementById('myForm').style.display = 'block';
  });
</script>