【发布时间】:2015-12-08 23:46:17
【问题描述】:
我有多个按名称区分的单选按钮,这是我的脚本
<?php
if(mysqli_num_rows($result)>0){
while($row = $result->fetch_assoc()){ ?>
<tr>
<td><?php echo $row['fullname'];?></td>
<td><?php echo $row['email'];?></td>
<td><?php echo $row['class'];?></td>
<td><input type="radio" value="present" name="<?php echo($row['id']); ?>" checked></td>
<td><input type="radio" value="absent" name="<?php echo($row['id']); ?>"></td>
</tr>
<?php }
}
?>
我想将它们的值传递给 php 脚本,如何传递每个单选按钮组的值,假设 mysql 查询返回 10 行,那么有 10 个单选按钮组,我需要发送单选按钮的所有值。 而我的 ajax 调用是
$("#submitAttendance").click(function(){
$.ajax({
url: 'teacher.php',
method: 'post',
data:
});
});
【问题讨论】:
-
#submitAttendance在哪里?请粘贴完整代码。 -
您要发送所有值还是选定值?前者有点奇怪。如果是后者,请使用
$('form').serialize() -
@RoryMcCrossan 你混淆了前者和后者。
-
不,这是正确的方法。
-
我只想发送所有选定的值并且我没有使用表单?还有其他方法吗? @RoryMcCrossan
标签: php jquery ajax radio-button