CSDN博客

img zzz_781111

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

发表于2008/9/29 15:00:00  713人阅读

分类: asp php

----------------------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" onkeyup="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" onkeyup="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

相关文章推荐

img
取 消
img