AJAX表单仅限PHP,我关注优雅降级

AJAX表单仅限PHP,我关注优雅降级

问题描述:

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.

我有一个PHP驱动的网站,它有一个记录保存表单。 用户在第一个下拉列表中选择一个战斗,然后在第二个下拉列表中选择获胜的一方。 目前,获胜方选项仅在战斗设置中首先列出了 Side 1,Side 2 code>。 提交内容“你确定吗?” 如果他们选择了错误的一方,请确保他们有机会纠正方。 p>

我是第一个承认这很烦人的人,并希望让胜利的一方下拉填充 自动根据所选的战斗。 我被告知这是一个非常棒的AJAX东西。 p>

但我担心的是如何维护JS禁用用户的功能。 这种下拉式自动填充可以带有原始的PHP固定值吗? p>

很抱歉缺少代码。 我还没有开始研究JavaScript和AJAX方法,只是考虑到我的网站的理论应用程序...... p>

谢谢。 p> div >

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

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.