但是对于 radio 来说这是如何完-6ren">
gpt4 book ai didi

php - 还记得在 php 页面上向 self 提交表单时的 "Radio"值吗?

转载 作者:行者123 更新时间:2023-11-28 14:04:39 26 4
gpt4 key购买 nike

在文本输入上,如果表单提交给自身,这就是您“记住”用户输入的值的方式,例如图片上传工具需要这样做,因此用户不必在表单中输入所有内容上传图片后再次查看。

   <input type="text" id="text" name="text" value="<?php echo @$_POST['text'];?>">

但是对于 radio 来说这是如何完成的呢?

我不想用 php 创建实际的 radio ,我更喜欢另一个解决方案。但最终我会选择最简单的! Javascript在这里也可以使用!

谢谢

最佳答案

<input type="radio" id="radio_button_1" name="radio_button" value="1"<?php if($_POST['radio_button'] == 1) { print ' checked="checked"'; } ?> />
<input type="radio" id="radio_button_2" name="radio_button" value="2"<?php if($_POST['radio_button'] == 2) { print ' checked="checked"'; } ?> />

关于php - 还记得在 php 页面上向 self 提交表单时的 "Radio"值吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2283591/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com