I am trying to build a downloads section where the visitor completes a form and then selects check boxes to open download dialogs.
I would like the form to submit and the dialogs to open, when the button is clicked.
I am not very good at writing scripts, although I can read them. Currently I can only get one or the other to work!
The form is a standard PHP form....
This is the javascript I am using
var suffix=1;
function downloadAll(oFrm){
var oChk = oFrm.elements["file"+(suffix++)];
if (oChk){
if (oChk.checked){
location.href = oChk.value;
setTimeout(function(){downloadAll(oFrm)}, 2000);
}
else{
downloadAll(oFrm);
}
}
}
This is an abbreviated part of my HTML
<input type="checkbox" name="file1" id="file1" value="/download.php?f=blank.gif" /><label for="file1">blank.gif</label>
<input type="checkbox" name="file2" id="file2" value="/download.php?f=atlas_blue_hover2.png" /><label for="file2">atlas_blue_hover2.png</label>
<input type="checkbox" name="file3" id="file3" value="/download.php?f=Tabs.css" /><label for="file3">Tabs.css</label>
<input type="button" value="Download All" onClick="suffix=1;downloadAll(this.form);return false;" />
I think that this might not be working because the onclick cancels out post in a PHP form
method="post" action="http://url"
Can I do similar to above using onSubmit? Or using the checkbox values in PHP?
Any help would be appreciated.