发布后保留单选按钮值
您好,
我正在使用 php 页面,我需要在发布页面后保留复选框和单选按钮(选中或未选中)的值。
我怎样才能做到呢?
谢谢
HI
i'm using a php page and i need to keep the value of and check box and radio button (checked or not checked) after post page.
how could i make it?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先获取单选按钮的值。
然后对于每个具有相同名称的单选按钮,执行以下操作
First get the radio button value.
Then for each radio button with the same name, do this
您需要类似的东西:-
这段代码应该可以帮助您继续。我基本上是检查复选框/单选元素的 POST 值是否已设置 &相应元素的值是否与我各自元素的值匹配。
希望有帮助。
You need something like:-
This code should get you going. I'm basically checking whether the POST value of either the checkbox / radio element is set or not & whether the corresponding element's value matches with my respective element's value or not.
Hope it helps.
像这样的事情:
会发生的情况是,您检查输入变量是否在
$_POST
中,如果是,则将checked="checked"
添加到输入字段以使其检查过。Something like this:
What happens is that you check if the input variables are in the
$_POST
and if so you addchecked="checked"
to the input fields to make them checked.这对我有用,并且是不言自明的
示例代码用法:
This worked for me, and is self explanatory
sample code usage: