What I do is put a script on my main page (not in an external file) that consists solely of an object definition like this:
var Controls = {
'Name':<%="'" + txtNumberOfDrugsInKit.ClientID%>',
'OtherName':<%="'" + otherControl.ClientID%>'
};
The trick here is that you have to put this in the header or you can't use it from external files, and so you have to add runat="server"
to your head element declaration. This also explains why I use an object rather than simple variable names; it minimizes the chance for a naming collision elsewhere (I only have the "Controls" name to worry about).
Then I can use that Controls object in an external script like this:
var OtherElement = document.getElementById(Controls.OtherName);
or
var jQueryObj = $('#' + Controls.OtherName);
See another example here:
Can I count on ctl00_PagePlaceHolder_myId staying the same?