jquery获取选中的checkbox并提交form表单

gamecalo 2012-10-19

/HTML

<formmethod="POST"name="subForm"id="subForm"action="/report/mail/redirectEmail/"enctype="multipart/form-data">

<inputtype="checkbox"name="memberContactIds"value="${memberContacts.id}"style="width:15px;"checked="checked">

<inputtype="button"onclick="send_emails()"value="点击">

</form>

//JS

functionsend_emails(){

varsel=$("input:checkbox[checked=true]");

if(sel.length==0){

alert("请选择收件人!");

returnfalse;

}else{

$("#subForm").submit();

loading();

}

}

//Action

publicStringredirectEmail(LongmemberId,Long[]memberContactIds,@RequestParam(value="fileString",required=false)MultipartFile[]fileString,@ModelAttributeReportreport,BindingResultresult,SessionStatusstatus,Modelmodel,HttpServletRequestrequest,HttpServletResponseresponse)

{

StringBuffersb=newStringBuffer();

if(null!=memberContactIds&&memberContactIds.length>0)

{

for(Longl:memberContactIds)

{

System.out.println(l);

sb.append(l+",");//用逗号拼成这样的形式:111,222,333,

}

}

List<String>fileStrings=newArrayList<String>();

report.setType(0);

report.setSendType(4);//给一个公司下面的多个用户发送

report.setMemberContactIds(sb.toString());

String[]ids=report.getMemberContactIds().split(",");

if(null!=ids&&ids.length>0)

{

for(Stringid:ids)

{

MemberContactmemberContact=memberContactService.findById(Long.valueOf(id));

}

}

}

相关推荐

我的程序员人生 / 0评论 2011-08-24