//判断是否有选择的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;"/>
全选删除JS
最新推荐文章于 2022-06-06 09:46:21 发布