I have a table that has a list of files and each row/file has a checkbox associated with it. A user can check these boxes and then click a download button and the idea would be to have each file be fired up as a separate download.
The way I have this set up is a form wraps around the table, and then there's a final input that calls downloadChecked when clicked. I have copied the function below. My problem is that this setup will only download the *last* checked item as it loops through, not *every* checked item. I have already verified the code gets inside the if statement when it should. How can I modify this to get the desired effect, or is there a different/better way to do this?
The way I have this set up is a form wraps around the table, and then there's a final input that calls downloadChecked when clicked. I have copied the function below. My problem is that this setup will only download the *last* checked item as it loops through, not *every* checked item. I have already verified the code gets inside the if statement when it should. How can I modify this to get the desired effect, or is there a different/better way to do this?
Code:
function downloadChecked( )
{
for( i = 0 ; i < document.downloadform.elements.length ; i++ )
{
foo = document.downloadform.elements[ i ] ;
if( foo.type == "checkbox" && foo.checked == true )
{
document.location.href='somefile.do?command=download&fileid=' + foo.name ;
}
}
}