Question

I've got a PHP-driven site that has a recordkeeping form. The user chooses a battle in the first dropdown, then the winning side in the second. Currently the winning side options are only Side 1 , Side 2 corresponding to which was listed first in the battle setup. The submission has an "are you sure?" step to make sure they have a chance to correct the side if they chose the wrong one.

I'm the first to admit this is annoying, and want to make the winning side dropdown populate automatically based on the battle selected. I've been told this is bread-and-butter AJAX stuff.

My concern, though, is how to maintain functionality for JS-disabled users. Can this sort of dropdown auto-population carry the original PHP fixed values behind it?

Sorry for the lack of code. I haven't yet begun to study JavaScript and AJAX methods, just considering the theoretical applications to my site at this point...

Thank you.

Was it helpful?

Solution

You could do it like this. When the page loads, if javascript support is enabled, the button/link which does the post is hidden and the site works with javascript otherwise the button/link is displayed and the site works without js

OTHER TIPS

I'm not the AJAX guru but your idea sounds good. You can of course populate a drop down list and JS enabled browsers can remove/repopulate/alter/... this field whatever they like by loading data via an AJAX request.

With a little bit of googling, you should be able to find such already-developed solutions or at least get an idea of what others have done.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top