全选删除JS


//判断是否有选择的checkbox
function selectCheck()
{
for(var i=0;i<document.forms[0].elements.length; i++)
{
if(document.forms[0].elements[i].type=='checkbox')
{
if(document.forms[0].elements[i].checked==true)
{
return true;
}
}
}
return false;
}


function delSelect()
{
var select="";

if(!selectCheck())
{
alert("请先选中要删除的信息!");
return;
}

//当只有一条记录时,会成null
if(document.all.checknum.length==null)
{
select += document.all.checknum.value + ",";
}

//多条记录时
for(var i = 0; i < document.all.checknum.length; i ++)
{
if(document.all.checknum[i].checked == true)
{
select += document.all.checknum[i].value + ",";
}
}
if(confirm("删除后将不能恢复,您确认执行删除操作么?"))
{
//去掉最后的逗号
select = select.substr(0, select.length - 1);
alert(select);
document.forms[0].action="ylajax.do?Method=deleteRow&select="+select;
document.forms[0].submit();
return ;
}
}

<td><input type="checkbox" name="checknum" value=<bean:write name="s" property="sno"/>></td>


ACTION:
public ActionForward deleteRow(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
StudentForm sg = (StudentForm)form;
List<String> list = new ArrayList<String>();
String check = request.getParameter("select");
String [] id = check.split(",");
for (int i = 0; i < id.length; i++)
{
list.add(id[i]);
}
ProccessStu.getStu().delStudentTex(list);
List<StudentTex> lists = ProccessStu.getStu().getStudentTex();
sg.setStu(lists);
return mapping.findForward("initial");
}
//全选----------------------------------------------------------------------------------
function selectAll()
{
for(var i=0;i<document.forms[0].elements.length;i++)
{
if(document.forms[0].elements.type='checkbox')
{
if(document.forms[0].check.checked==true)
{
document.forms[0].elements[i].checked=true;
}
else
{
document.forms[0].elements[i].checked=false;
}
}
}
}

<input type="checkbox" name="check" onClick="selectAll();" >
窗口弹出在中间页面-----------------------------------------------------------------
function openwindow( url, winName, width, height)
{
xposition=0; yposition=0;
if((parseInt(navigator.appVersion) >= 4 ))
{
xposition = (screen.width - width) / 2;
yposition = (screen.height - height) / 2;
}
theproperty ="width=" + width + "," + "height=" + height + "," + "location=0," + "menubar=0," + "resizable=1," + "scrollbars=0," + "status=0," + "titlebar=0,"
+ "toolbar=0," + "hotkeys=0," + "screenx=" + xposition + "," //仅适用于Netscape
+ "screeny=" + yposition + "," //仅适用于Netscape
+ "left=" + xposition + "," //IE
+ "top=" + yposition; //IE
window.open( url,winName,theproperty );
}

JS不能键盘输入---------------------------------------------------------------------------
<html:file property='uploadFile' styleClass="btn" size="50" onkeydown="if(event.keyCode!=9 && (event.keyCode<35 || event.keyCode>40)) return false;"/>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值