为了账号安全,请及时绑定邮箱和手机立即绑定

我有两个复选框“接受”和“拒绝”并提交按钮。当我点击提交按钮时,它应该检查勾选了哪个复选框

我有两个复选框“接受”和“拒绝”并提交按钮。当我点击提交按钮时,它应该检查勾选了哪个复选框

天涯尽头无女友 2021-10-29 16:05:52
{ field: "Accept", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.AcceptChk), "template": "<input type=\"checkbox\" # if (checkCommentsAccept(data.Comments)) { #disabled=\"disabled\" # } # />" },{ field: "Decline", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.DeclineChk), "template": "<input type=\"checkbox\" # if (checkCommentsDecline(data.Comments)) { #disabled=\"disabled\" # } # />" },{ field: "Item", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.Item) },{ field: "PartID", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.PartID) },{ field: "Description", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.Description), width: '300px' },{ field: "SubPart", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.SubPart) },{ field: "SubPartDescription", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.SubPartDescription) },{ field: "BusinessPartner", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.BusinessPartner) },{ field: "ReqDelTM", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.ReqDelTM) },{ field: "EarDelTM", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.EarDelTM) },{ field: "EarDelDate", title: "Ear Del Date", hidden: true },{ field: "Comments", title: commonLib.readMessageByUserLanguage(COLUMNTITLENAME.Comments) }当我点击提交按钮时,它应该检查接受复选框是否被选中,如果被选中,那么我有一些逻辑。如果拒绝复选框被选中,那么我有一些其他的逻辑。
查看完整描述

2 回答

?
SMILET

TA贡献1796条经验 获得超4个赞

如果有复选框,您可能已经实现只选中单个复选框,对吗?,否则可能会选中接受和拒绝两个复选框,


假设您已经实现了单选复选框逻辑


$( "form" ).submit(function( event ) {

  event.preventDefault();

  if($("input[type='checkbox']:checked")[0].val() == 'Allow'){

    // things to done on allowed

  }else  if($("input[type='checkbox']:checked")[0].val() == 'Declined'){

    // things to done on declined

  }else{

    // rest things 

  }

});

您可能需要稍微更改代码,但它会根据您的需要在逻辑上工作。


查看完整回答
反对 回复 2021-10-29
  • 2 回答
  • 0 关注
  • 213 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号