You have to send request to the server to check if the file exists unless you have already loaded the list to javascript. But you can also do it purely client-side by using the
XMLHTTP object.
Since you only need to check if the file exists, just change the line in that script:
return oxmlhttp.responseText;
to:
return (oxmlhttp.status==200) ? true:false;
which means the function returns true if the file exists and false otherwise.
And I noticed that you're accessing the value of the comboboxes using
comboboxRef.value. Only few browsers support that. This is the cross-browser way:
var pdfLink = '../menus/';
var f = document.form1;
pdfLink += f.mnuMeal.options[f.mnuMeal.selectedIndex].value;
pdfLink += f.mnuDay.options[f.mnuDay.selectedIndex].value;
pdfLink += f.mnuMonth.options[f.mnuMonth.selectedIndex].value;
or better, pass the form reference to the function
function buildLink(
f)
{
var pdfLink = '../menus/';
pdfLink += f.mnuMeal.options[f.mnuMeal.selectedIndex].value;
pdfLink += f.mnuDay.options[f.mnuDay.selectedIndex].value;
pdfLink += f.mnuMonth.options[f.mnuMonth.selectedIndex].value;
...
}
...
<input type="button" value="View Menu" onclick="buildLink(
this.form);">