how to accepte the array of the checkbox in asp and in php

2 篇文章 0 订阅
----------------------the form which will post checkbox array----------------
    <form name="form<%=rs("id")%>" method="post"   action="xinruku.asp?key=c&sk=<%=sk%>&shangpinmingcheng=<%=spmc%>&id=<%=rs("id")%>" style="margin:0px">
        
 


  <%
  if zhonglei="chengpin" then
            strSql="select * from good_list where zhonglei='配件' order by id desc"
            pnum=0
            Set rstData =conn.execute(strSql)
            Do while Not rstData.EOF      
                pnum=pnum+1
        
                 %>
                   <input   type="checkbox"   name="chk"   value="<%=rstData("ID")%>"     align=left      >   <%=rstData("good_name")%>    
                 <%
                 if pnum mod 2 =0 then
                     'response.Write("<br>" )
                 end if
                 response.Write("<br>" )
                rstData.MoveNext  
            loop  
            rstData.Close  
            set rstData = nothing
 end if

  %>
         增加数量
          <input name="good_num" type="text" id="good_num" style="width:30px" οnkeyup="this.value=this.value.replace(//D/g,'')" onafterpaste="this.value=this.value.replace(//D/g,'')">
          <%if session("tech_user_clas")=1 then%>
          <br />          
          重置数量
          <input name="now_shuliang" type="text" id="now_shuliang"  style="width:30px" οnkeyup="this.value=this.value.replace(//D/g,'')" onafterpaste="this.value=this.value.replace(//D/g,'')"/>
          <br />
          <%end if%>
          <input type="submit" name="Submit2" value="确定">
        </form>     
------------------------how to accepte the array of the checkbox-------------------------
 for   i=1   to   request.form("chk").count    
      StrCheck=  request.form("chk")(i)  
    '  response.Write("<script>alert('"&StrCheck&"');</script>")
    
     sql="update good_list set good_num=good_num-"&good_num&" where id="&StrCheck
     conn.execute(sql)

  next


---------------in php you should get the array of the same name of  checkboxes as below--------------------------------------------
---------------the form-------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>annie</title>

</head>

<body >
抓取基础链接
<form method="post" action="getall.php"   style="padding-bottom:5px; padding-top:5px;">
<span class="red_font">请输入关键词 :</span>
<input name="query_keyword" class="input_box" value="" style="width:150px;"/> <br>
选择搜索引擎
<input type="checkbox" name="mybox[]" value="google">google
<input type="checkbox" name="mybox[]" value="baidu">百度<br>

<input type="submit" class="input_box" value="提交"  />
</form>
------------------------how to get the data--------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>annie</title>
 
</head>

<body >

<?php
$mybox=$_POST['mybox'];
$myboxcount= count($mybox);
echo $myboxcount."<br>";
for($i=0;$i<$myboxcount;$i++)
{
    echo  $mybox[$i]."<br>";
}

  ?>
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值