diarratech
Technical User
"list" is a check box on a form.
This script is supposed to check if a user selected a check box or not before deletion. It works great except when there is only one check box left. Javascript sees the value of the check box as "undefined."
(I used that script to delete rows on a form)
The following script:
{alert("Number of checkboxes = " + " " + maxi);} is just like a message box that I displayed for myself to see the value of "maxi" which is undefined when there is only one box left. When I try if (maxi>1), it automatically jumps to the else statement:
else{
alert ("Checkbox not checked"
;
return false;
}
as if no checkbox was checked. I also tried to add 1 to maxi (if maxi == "undefined" or if maxi ==0 ...) but nothing works.
Here's the script
function confirmSubmit()
{
var total = 0;
var maxi = frmDeletion.list.length;
{
alert("Number of checkboxes = " + " " + maxi);
}
for (var idx = 0; idx < maxi; idx++)
{
if (eval("frmDeletion.list[" + idx + "].checked"
== true)
{
total += 1;
}
}
if (total > 0)
{
alert("Total checkboxes checked =" + " " + total);
var agree=confirm("Do you want to delete " + total + " row(s) ?"
;
if (agree)
{
return true ;
}
else
{
return false ;
}
}
else
{
alert ("Checkbox not checked"
;
return false;
}
}
This script is supposed to check if a user selected a check box or not before deletion. It works great except when there is only one check box left. Javascript sees the value of the check box as "undefined."
(I used that script to delete rows on a form)
The following script:
{alert("Number of checkboxes = " + " " + maxi);} is just like a message box that I displayed for myself to see the value of "maxi" which is undefined when there is only one box left. When I try if (maxi>1), it automatically jumps to the else statement:
else{
alert ("Checkbox not checked"
return false;
}
as if no checkbox was checked. I also tried to add 1 to maxi (if maxi == "undefined" or if maxi ==0 ...) but nothing works.
Here's the script
function confirmSubmit()
{
var total = 0;
var maxi = frmDeletion.list.length;
{
alert("Number of checkboxes = " + " " + maxi);
}
for (var idx = 0; idx < maxi; idx++)
{
if (eval("frmDeletion.list[" + idx + "].checked"
{
total += 1;
}
}
if (total > 0)
{
alert("Total checkboxes checked =" + " " + total);
var agree=confirm("Do you want to delete " + total + " row(s) ?"
if (agree)
{
return true ;
}
else
{
return false ;
}
}
else
{
alert ("Checkbox not checked"
return false;
}
}