<script language="javascript">
function check(){
var strchoice="";
for(var i=0;i<document.info.choice.length;i++){
if (document.info.choice[i].checked) {
strchoice=strchoice+document.info.choice[i].value+",";
}
} if (!document.info.choice.length) {
if (document.info.choice.checked) {
strchoice=document.info.choice[i].value;+","
}
}
strchoice=strchoice.substring(0,strchoice.length-1);
document.info.choiceid.value=strchoice;
alert(document.info.choiceall.value);
}
</script>
用这个把,那获得全部的值
function check(){
var strchoice="";
for(var i=0;i<document.info.choice.length;i++){
if (document.info.choice[i].checked) {
strchoice=strchoice+document.info.choice[i].value+",";
}
} if (!document.info.choice.length) {
if (document.info.choice.checked) {
strchoice=document.info.choice[i].value;+","
}
}
strchoice=strchoice.substring(0,strchoice.length-1);
document.info.choiceid.value=strchoice;
alert(document.info.choiceall.value);
}
</script>
用这个把,那获得全部的值
解决方案 »
- 批量上传照片
- js字符串分页显示的问题,在线等
- 用php怎样才能获取邮件服务器上的邮件列表呢,着急啊,在线等。。。
- 静态的文章页面中的动态内容实现
- 关于PHP程序实现向数据库上传图片的一段代码的问题
- PHP之高手的崛起3,欢迎大家加入!
- myskya进来拿分。
- 如何抓取站外网页的内容并处理抓取的结果
- 救救菜鸟:linux下的php怎么安装,怎么连接oracle数据库?
- 很菜问题,用php如何实现:定时发信?
- 有奖调查:大家觉得哪个论坛比较好,支持同时在线人数多,速度快,使用方便,功能强动网http://www.dvbbs.net?OR紫桐http://www.phpx.co
- 按照比例随机出现.
<input type="checkbox" name="checkbox[]" value="123">
123
<input type="checkbox" name="checkbox[]" value="234">
234
<input type="checkbox" name="checkbox[]" value="asd">
asd
<input type="checkbox" name="checkbox[]" value="qwe">
qwe
<input name="" type="submit">
</form>
<?print_r($checkbox);?>
<input type=\"hidden\" name=\"choiceid\"><input type=submit value=\"获得\">
choice是checkbox name=choice
$_POST['checkboxname'],这是一个数组,checkboxname的值就存在于这个数组中,第一个就是 $_POST['checkboxname'][0],以此类推
这不是我的方法,这是php的约定。
php对表单变量命名时有一个小小的要求:同名的表单变量要写成数组形式,否则他不认得。
http://www.blueidea.com/bbs/NewsDetail.asp?id=1256952
===================================================
后台读取选中的值
print_r($_POST['checkbox'])将其保存为asp的多选框格式
echo implode(",",$_POST['checkbox'])