Javascript try...catch - 2 identical calls, only one works
<p>I'm in the process of redesigning a menu/submenu - just moving the submenu from somewhere in the bottom of the page to under its corresponding menu item. Right now, the same submenu (actions) is found twice in page, only that one of the times it's hidden and displayed with jQuery on mouse over. In both menus I have an option pointing to a function with a try...catch block. </p>

<p>Here's the problem, when using the jQuery-displayed actions, Javascript crashes in the try block ("something" is undefined - classical), just like the word 'try' wasn't even there. I've used the firebug debugger, and the same error occurs when using the other submenu, but that was just skipped and the code from inside catch was executed.</p>

<p>I just don't understand how this is possible, given that both options call THE SAME function, not 2 "identical" ones...</p>

<p>Any thoughts? Thanks :)</p>

<p><strong>EDIT I:</strong></p>

<pre><code>function export_pdf() {
            try {
                ReportType=document.forms["down"].elements["ReportType"].value;
            }
            catch (e) {
                ReportType='TDR_Report';
            }

            //other code...
}
</code></pre>

<p>And the error is "document.forms.down.elements.ReportType is undefined"...</p>

<p>Thanks!</p>

<p><strong>EDIT II:</strong></p>

<p>Calling the function:</p>

<pre><code>onclick="export_pdf();"
</code></pre>
