halo there..i hope i can get some solutions at here..i have do some research..but until now, i still cant understand the information get from the net. i hope u all can give some help.

i wan to do a validation for checkbox which the checkbox will loop with the database record, and the checkbox is same name with value is the product id.
Code:
<input type="checkbox" name="deleteproduct" value="<%=rsDisplay("ProductMasterID")%>"/>
then when i click on the DELETE button , when onclick it will call a function in JS (DeleteProduct()).
below is the JS i try to write.

Code:
function DeleteProduct()
        {
        var checkSelected=false;
        for(var i=0;i<document.productlist.deleteproduct.length;i++)
          {  
            var total=0;
            if (document.productlist.deleteproduct[i].checked){
	            checkSelected=true;       
	            total=total+1;   //total selected 
                }
            for(var j=0;j<total;j++)
               { 
                document.productlist.action="delete_product.asp?productid="+document.productlist.deleteproduct[i].value;  
                document.productlist.submit();
               }
          }
         if(!checkSelected){
	         alert("Please select at least one record for delete.");
	         return false;
         }
        }
i met some problem from this code, i hope can get some help or guidance to improve the code that i write..plz help.
the problem and the requirement cant meet:
1. i wan to do a validation, after the multiple checkboxes are clicked, then will alert a confirmation to ask the user confirm to delete or not. if true, then cont the code and pass the looping value to the delete_product.asp pages to execute it.
2. i wan to do a validation,if no any checkbox is clicked but the delete button is press, then alert : choose one to delete.
3. form the code above, when my table has the last record, it stil pop up the alert to ask me to "Please select at least one record for delete" even i have check the last checkbox..i cant find any solution..

i hope can hear frm u all soon. i m quite poor in JS ...hope u all teach me..thanx alot..