PHP develops si...LOGIN

PHP develops simple voting system administrator function module (3)

115.png

As shown in the picture, there are three options in the click button here: select all, cancel all and delete selected.

Click these buttons to select all items, deselect all items, and delete all selected voting items

First set the name attribute of the <form> form

<form id="frm" name="frm" method="post" action="" style="margin-bottom:3px;"></form>

In The name attribute is also used in <input>.

<input type="checkbox" name="itm"/>

And give each of the following 3 button buttons an onclick event

<input type="button" value="选择全部" onclick="selectAll()" />
<input type="button" value="取消全部" onclick="cancelAll()" />
<input type="button" value="删除所选" onclick="del()" />

Use javascript to implement the function module of all click events, A for loop is used here to mark the selection.

Click "Select All" to make all checkboxes checked=true, click "Cancel All" to make all checkboxes checked=false unchecked.

If the check box is not selected, it means that the content ID is not selected. Click "Delete Selected" and the content will not be deleted and a prompt message will be displayed.

You can select a single ID to delete, or you can select all to delete.

<script language="javascript">
  function selectAll()  //选中所有
  {
    node=window.document.frm.itm;
    for(i=0;i<node.length;i++)
    {
      node[i].checked=true;
    }
  }
  function cancelAll() //取消选中所有
  {
    node=frm.itm;
    for(i=0;i<node.length;i++)
    {
      node[i].checked=false;
    }
  }
  function del() //删除选中的所有
  {
    node=frm.itm;
    id="";
    for(i=0;i<node.length;i++)
    {
      if(node[i].checked)
      {
        if(id=="")
        {
          id=node[i].value
        }
        else
        {
          id=id+","+node[i].value
        }
      }
    }
    if(id=="")
    {
      alert("您没有选择删除项");
    }
    else
    {
      location.href="?type=del&id="+id
    }
  }
</script>


Next Section
<input type="button" value="选择全部" onclick="selectAll()" /> <input type="button" value="取消全部" onclick="cancelAll()" /> <input type="button" value="删除所选" onclick="del()" />
submitReset Code
ChapterCourseware