AJAX 形式与仅 PHP 形式,我担心优雅降级

发布于 2024-09-10 14:14:10 字数 362 浏览 1 评论 0原文

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

我是第一个承认这很烦人的人,并且希望根据所选的战斗自动填充获胜方下拉列表。有人告诉我这是 AJAX 的主要内容。

不过,我关心的是如何为禁用 JS 的用户维护功能。这种下拉自动填充可以在其后面携带原始PHP固定值吗?

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

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夕嗳→ 2024-09-17 14:14:10

你可以这样做。
页面加载时,如果启用了 javascript 支持,则执行帖子的按钮/链接将被隐藏,并且该网站可以使用 javascript 运行,否则将显示按钮/链接并且该网站可以在没有 js 的情况下运行

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

寄与心 2024-09-17 14:14:10

我不是 AJAX 专家,但你的想法听起来不错。当然,您可以填充下拉列表,并且支持 JS 的浏览器可以通过 AJAX 请求加载数据来删除/重新填充/更改/...该字段,无论他们喜欢什么。

通过一些谷歌搜索,您应该能够找到此类已经开发的解决方案,或者至少了解其他人所做的事情。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文