通过URL传递String数组值的最佳方法

时间:2014-05-22 06:54:51

标签: javascript checkboxlist arrays

我需要通过URL传递字符串数组内容。 String数组可以包含100 - 10000个值。我得到了类似的问题link,但在我的情况下,它包含大量数据。

使用comma (,)是传递值的最佳方法,还是有其他方法可以解决此问题。

我在javascript function中使用此功能,其中String array包含所有选定的checkbox list值。

<script type="text/javascript">
function doResend(){
var checkboxes = document.getElementsByName('selectedId');
var vals = "";
for (var i=0, n=checkboxes.length;i<n;i++) {
  if (checkboxes[i].checked){
    vals += ","+checkboxes[i].value;
  }
}
if (vals){
vals = vals.substring(1);
window.open('resendSelectedSMS.do?smsId='+vals,"mywindow","status=1, height=335, width=400',resizable=0");
}else{
alert("Select atleast one id");
}
}
</script>

1 个答案:

答案 0 :(得分:1)

最佳方法是使用get-post:

http://www.w3schools.com/tags/ref_httpmethods.asp

看起来像这样的东西:

/test/demo_form.asp?name1=value1&name2=value2