javascript验证checkbox,求答案!!!

主页上有一行行订单记录,每行最前面有个checkbox,最上面一行(标题行)有个全选的checkbox,订单有状态属性,分别是三种:新出、处理中、处理完成。

主页上还有一个处理按钮,用来改变订单的状态。

当 不选中行 的时候,点击处理按钮时,希望用JavaScript弹出对话框提示:请选择订单!

当选中的订单的状态是 新出 的订单时,弹出对话框提示:是否处理?

当选中的订单的状态不是新出时,弹出对话框提示:选择有误,请重新选择!

怎么样才能实现呀?不用后台验证,望前辈告知!!!

我的想法是在javascript中先获取所选中订单的一个或者多个ID,循环得到一个或者多个对象,再得到他们的状态,只要有一个不满足条件就break,将中间设定的参考变量变为相反。
具体怎么弄,还望大家帮忙,我是刚入行的小白,谢谢!下面是我的jsp代码,头部的javascript代码、input标签里的onclick写的不对,望改正,其他地方改不得呀~~~

<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>


function validateState(ids,alertMsg,theFrm,actionUrl){ var a=false; for(var i=0;i<document.all(ids).length;i++){ if(document.all(ids)[i].checked==true){ a=true; } } if(a){ if(confirm(alertMsg)){ if(""!=actionUrl){ theFrm.action=actionUrl; } theFrm.submit(); } }else{ alert("请选择新开订单"); return false; } }





onclick="validateState('ids','是否处理',this.form,'')">


订单号订单主题状态下单时间
${vo.orderNumber}${vo.orderTheme}${stateMap[vo.stateId]}

/html:form

function getSelectedChks(name){
var inputs = document.getElementsByTagName('input');
var chks = [];
var count = inputs.length||0;
while(count--){
var input = inputs[count];
if(input.getAttribute('type')=='checkbox'&&input.getAttribute('name')==name){
if(input.checked){
chks.push(input);
}
}
}//end while
return chks;
}
//假设${stateMap[vo.stateId]} 值为 1 2 3; 1:新出 2:处理中 3:完成
function getState(dom){
var td = dom.parentNode.nextSibling.nextSibling.nextSibling;
if(td.tagName=='TD') return td.innerHTML;
else return null;
}

function check(chks){
if(chks.length==0) {
alert('请选择');return false;
}

for(var i=0;i<chks.length;i++){
    var chk = chks[i];
    var state = getState(chk);
    if(state===null||state!=1){//1:新出 
        alert('选择有误,请选择新开订单'); return false;
    }
}  
return true;

}

function validateState(name,alertMsg,theFrm,actionUrl){
var chks = getSelectedChks(name);
if(check(chks)){
if(confirm(alertMsg)){
if(""!=actionUrl){
theFrm.action=actionUrl;
}
theFrm.submit();
}
}
}

传进来的当然是 'ids' 了。