Home >Backend Development >PHP Tutorial >js获取的值放入数组,在传到php文件,咋整?()

js获取的值放入数组,在传到php文件,咋整?()

WBOY
WBOYOriginal
2016-06-13 10:07:14929browse

js获取的值放入数组,在传到php文件,咋整?(在线等)
js代码:
function queren(){
  var arr = new Array();
  var checkbox = document.getElementsByName("name");
  for(var i = 0 ; i   if(checkbox[i].checked == true){
  arr[i] = checkbox[i].value;
  }
  }
}

我想把checkbox[i].value的值都赋给arr[i],然后在php文件接受, js写的对吗?php文件又该怎么接收?新手求代码。。。。

------解决方案--------------------
用ajax来操作
------解决方案--------------------

PHP code
function queren(){  var arr = new Array();  var checkbox = document.getElementsByName("name");  for(var i = 0 ; i <checkbox.length i if true arr checkbox : function></checkbox.length><font color="#e78608">------解决方案--------------------</font><br>1.用AJAX,返回数据类型用json<br>2.用AJAX,返回字符串,形式类似str1,str2,str3 ,PHP接收后再用explode处理成数组。<br><br><div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn