I have this section of code:
function createDownload() {
var category, format, specification, download;
$('#submitform').click(function() {
category = $('#cate').val();
format = $('#form').val();
specification = $('#spec').val();
if (category == "NULL" || format == "NULL" || specification == "NULL") {
alert("Please select all options.");
return false;
} else {
download = "pdfs/"+specification+format+category+".pdf";
window.open(download);
}
});
}
Now… In Internet Explorer it says there is an “Error on the page” – Message: 'return' statement outside of function and I have to click the button again.
In Firefox, Chrome and Safari – I have to click the button twice to get the PDF to appear… (and no errors)…
Now why could that be?!
As per request – My Form declaration:
<form method="post" action="javascript: return false;" onSubmit="createDownload();">
You need to change your
action='javascript: return false;'and remove theonsubmit. It should becomeaction='javascript: createDownload();'