I’m working on a travel planning form that adjusts based on the selected nationality. For example, if someone picks a country like India, the form should display whether they need an electronic visa for places like Sri Lanka, and maybe show a short message or guide link.
I’m using JavaScript to detect changes in a <select> dropdown and send that to a PHP file via AJAX. The PHP checks a list and responds with JSON.
But I’m running into a few issues:
Sometimes the JSON response is empty, even though it works in the browser.
Other times, the DOM update doesn’t reflect the new message.
What’s the best structure to manage these types of dynamic, country-specific conditions without hardcoding everything in JS?
Any feedback appreciated — especially if you’ve done something similar for multi-country forms.
✅ This version:
Avoids links and commercial terms
Focuses on technical workflow (AJAX, PHP, JSON)
Mentions <link removed by moderator> as an example, not a pitch