gpt4 book ai didi

php - 使用 $_GET 接收单选按钮的标签

转载 作者:行者123 更新时间:2023-11-28 12:52:02 24 4
gpt4 key购买 nike

我想将我的单选按钮的标签打印到一个单独的页面,使用类似于使用 php 的东西

<div class="radio"><?php echo "-" .  (!empty($_GET['radio']) ? $_GET['radio'] :'');?>

那将在另一页上,但这是第一页上带有单选按钮的代码。

<div class = "radio" required="required">
<h3 style = "margin-top:-20px;">Meaningless text.</h3>
<label for="x"><input type="radio" name="x" id = "x" /> <span>ex.1</span></label><br>
<label for="y"><input type="radio" name="x" id = "x" /> <span>ex.2</span></label><br>
<label for="z"><input type="radio" name="x" id = "x" /> <span>ex.3</span></label>
</div>

我在表单中有这个 div,当单击提交按钮时,表单重定向到带有 $_GET 的页面。我希望在单击选项时打印 ex.1、2 或 3。我试过了,我很难过。请帮忙!

最佳答案

为什么不设置 value归因于你所追求的......

<label for="x">
<input type="radio" name="x" id="x" value="ex.1">
<span>ex.1</span>
</label>
<label for="y">
<input type="radio" name="x" id="y" value="ex.2">
<span>ex.2</span>
</label>
<label for="z">
<input type="radio" name="x" id="z" value="ex.3">
<span>ex.3</span>
</label>

我还修复了你的副本 id属性。我假设来自 <label> from属性,它们应该是 x , yz .

$_GET['x'] 的值(假设 <form method="GET"> )将是 value选中的单选按钮。

<div class="radio">-<?= !empty($_GET['x']) ? $_GET['x'] : '' ?></div>

关于php - 使用 $_GET 接收单选按钮的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23555559/

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