我需要通过URL传递一个字符串数组内容。字符串数组可以包含 100 - 10000 个值。我有类似的问题link但就我而言,问题是它包含大量数据。
使用逗号 (,)
是传递值的最佳方法,或者是否有其他方法可以解决此问题。
我在javascript函数
中使用它,其中字符串数组
包含所有选定的复选框列表
值。
<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>
最佳答案
最好的方法是使用 get - post :
http://www.w3schools.com/tags/ref_httpmethods.asp
看起来像这样的东西:
/test/demo_form.asp?name1=value1&name2=value2
关于javascript - 通过 URL 传递字符串数组值的最佳方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23799770/