My problem,i have written a javascript to check whether the checkboxes are checked or not.If its not checked,i will get an alert message,if i checked then say it is checked.This condition is working for more than one data.If there is only one data and if i check that also,i am gettin an alert message and says its not checked.Please help me to solve this.
Javascript am using is,
Expand|Select|Wrap|Line Numbers
- var total=""
- for(var i=0; i < document.formname.field_id.length; i++)
- {
- if(document.formname.field_id[i].checked)
- total +=document.formname.field_id[i].value + "\n"
- }
- if(total=="")
- {
- alert("Please select one data")
- return false;
- }