jquery中选择checkbox拼接成字符串,然后到后台拆分取值
js中的代码
$("#btn").click(function(){ var chenked=$("input[type='checkbox']:checked").val([]);//此为重点 var names = ""; for(var i=0;i
后台代码拆分,不够灵活:
String names = null; String name1 = null; String name2 = null; names = request.getParameter("names"); String[] name = names.split(","); for(String x : name){ if("zhangsan".equals(x)){ name1 = x; } if("lisi".equals(x)){ name2 = x; } }