且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查复选框是否已选中

更新时间:2023-12-04 22:07:28

如果要在服务器端检查是否已选中复选框,则应执行以下操作:

If you want to check on server-side if a checkbox has been checked or not, you should do the following:

1。。将值添加到复选框

<input class="addToFavorite" type="checkbox" name="addToFavorite" value="addToFavourite"> Add to favorite</input> 

2。。在服务器端选中此复选框值

2. Check this checkbox value on server-side

if(request.getParameter("addToFavorite") == null){
    //checkbox not checked
}else{
    //checkbox checked
}