0
我无法在表单文章中获取选定单选按钮值。无论我选择哪个选项,我都会获得“开启”的值。请注意,这是在Wordpress插件选项页面中。无法在PHP表单中检索选定单选按钮值
代码如下形式:
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Title</h2>
<br />
<form action="options-general.php?page=page" method="post">
<table class="widefat">
<thead>
<tr>
<th></th>
<th>Site Name</th>
<th>Site URL</th>
<th>Username</th>
</tr>
</thead>
<tfoot>
<tr>
<th></th>
<th>Site Name</th>
<th>Site URL</th>
<th>Username</th>
</tr>
</tfoot>
<tbody>
<?php
$size = count($sites);
for ($i = 0; $i < $size; $i++) {
echo '<tr>';
for ($j = 0; $j < 4; $j++) {
if ($j == 0) {
echo '<td><input type="radio" id="cta_siteID_'.$i.'" name="cta_siteID",value="'.$i.'"/></td>';
}
else
{
echo '<td>'.$sites[$i][$j-1].'</td>';
}
}
echo '</tr>';
}
?>
</tbody>
</table>
<br />
<input type="hidden" name="formType" value="main" />
<select name="selectedItem">
<option value="" selected="true">Select an Option</option>
<option value="add">Add Site</option>
<option value="edit">Edit Site</option>
<option value="delete">Delete Site</option>
</select>
<input type="submit" name="Apply" value="Apply" class="button-primary" />
</form>
</div>
当我在电台组中选择一个项目后做的var_dump($ _ POST),我得到如下:
onarray(4){ [“cta_siteID”] => string(2)“on”[“formType”] => string(4)“main”[“selectedItem”] => string(4)“edit”[“Apply”] => string (5)“应用”}
值正在呈现正确发布表单之前的HTML,不知道发生了什么。
无论选择哪个无线电选项,“开”值都会显示出来,如果没有选择任何选项(根据我的预期),根本不会显示。
D'oh!应该抓住了!感谢您的帮助! – mjsalinger