php 复选框的用法 我原来在一个表中最前面加了一列复选框,现在我想以数组的形式读 出复选框的值,并显示被选中的复选框后面的一条记录,请各位大侠给点意见 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <input type="checkbox" name="c[]">1<input type="checkbox" name="c[]">2<input type="checkbox" name="c[]">3<?php$count = count($_POST['c']);echo $_POST['c'][$count-1]; //3?> <input type="checkbox" name="c[]">1<input type="checkbox" name="c[]">2<input type="checkbox" name="c[]">3能不能改为不固定的个数啊,就是用数组那样的,因为我的那个表是用数组输出的,行数挺多 是不是按纽的意思啊,我刚学,很多不明白,请前辈多多指教,for($n = 0; $n < 8; $n++){<input type="checkbox" name="c[]" value="1">}输出的只有一个,我想得到所有的,可以吗 <?phpvar_dump($_POST);?> 不知道该怎么跟你讲,参考代码:<script language=Javascript>function checkAll(e, itemName){ var aa = document.getElementsByName(itemName); for (var i=0; i<aa.length; i++) aa[i].checked = e.checked;}function checkItem(e, allName){ var all = document.getElementsByName(allName)[0]; if(!e.checked) all.checked = false; else { var aa = document.getElementsByName(e.name); for (var i=0; i<aa.length; i++) if(!aa[i].checked) return; all.checked = true; }}</script><form action="query.php" method="post" name="form1"> <table width="98%" border="0"> <tr> <td valign="top" nowrap>指定用户</td> <td nowrap><table width="462" border="0"> <tr> <td width="44" height="16">选择</td> <td width="180">公司名</td> <td width="107">用户名</td> <td width="113">用户姓名</td> </tr> <?php while ($row_user = $result_user->fetchRow(DB_FETCHMODE_ASSOC)) { ?> <tr> <td height='16'><input name="selectIt[]" type="checkbox" id="selectIt[]" value="<?php echo $row_user['user_id'] ?>"></td> <td><?php echo $row_user['user_category'] ?></td> <td><?php echo $row_user['user_uid'] ?></td> <td><?php echo $row_user['user_name'] ?></td> </tr> <?php } ?> </table></td> </tr> <tr><td> </td> <td colspan="2" nowrap> <input type=checkbox name=mmAll onClick="checkAll(this, 'selectIt[]')">全选与反选切换 </td></tr> <tr> <td colspan="2" nowrap> <input type="submit" name="Submit" value="提交"> <input name="Reset" type="reset" id="Reset" value="重置"> </td> </tr> </table></form> wasuka和wwx840723讲的很好啊!楼主好好看看。 php求救 菜鸟请教一个数组问题 一个安装php的问题, SESSION丢失的老问题,急急急 select选项框中所有的option值传给 php变量用, 菜鸟求教 document.createElement问题 [北京] 诚征PHP程序员一名,和LINUX服务器管理员一名 smarty,phplib,adodb我該用哪個好? 关于php.ini中include_path的问题 急 复选框问题
<input type="checkbox" name="c[]">2
<input type="checkbox" name="c[]">3<?php
$count = count($_POST['c']);
echo $_POST['c'][$count-1]; //3
?>
<input type="checkbox" name="c[]">2
<input type="checkbox" name="c[]">3能不能改为不固定的个数啊,就是用数组那样的,因为我的那个表是用数组输出的,行数挺多
for($n = 0; $n < 8; $n++)
{<input type="checkbox" name="c[]" value="1">}
输出的只有一个,我想得到所有的,可以吗
var_dump($_POST);
?>
<script language=Javascript>
function checkAll(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i<aa.length; i++)
aa[i].checked = e.checked;
}
function checkItem(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i<aa.length; i++)
if(!aa[i].checked) return;
all.checked = true;
}
}
</script>
<form action="query.php" method="post" name="form1">
<table width="98%" border="0"> <tr>
<td valign="top" nowrap>指定用户</td>
<td nowrap><table width="462" border="0">
<tr>
<td width="44" height="16">选择</td>
<td width="180">公司名</td>
<td width="107">用户名</td>
<td width="113">用户姓名</td>
</tr>
<?php while ($row_user = $result_user->fetchRow(DB_FETCHMODE_ASSOC)) { ?>
<tr>
<td height='16'><input name="selectIt[]" type="checkbox" id="selectIt[]" value="<?php echo $row_user['user_id'] ?>"></td>
<td><?php echo $row_user['user_category'] ?></td>
<td><?php echo $row_user['user_uid'] ?></td>
<td><?php echo $row_user['user_name'] ?></td>
</tr>
<?php } ?>
</table></td>
</tr>
<tr><td> </td>
<td colspan="2" nowrap>
<input type=checkbox name=mmAll onClick="checkAll(this, 'selectIt[]')">全选与反选切换
</td></tr>
<tr>
<td colspan="2" nowrap> <input type="submit" name="Submit" value="提交">
<input name="Reset" type="reset" id="Reset" value="重置"> </td>
</tr>
</table>
</form>