- Sorry, but I can't find the begining of something that would start to make any sense in your question. 
- It seems to be very specific to a particular context. You could perhaps succintly describe that context ... 
- ... and specifically what you are trying to achieve. 
Some hints, though : 
<a href="javascript:§some code here§;" §other relevant attributes§>;" ...>
is generally not a good idea : 
The HTML Anchor Element () defines a hyperlink to a location on the same page or any other page on the Web.
The element that is intended to react to a click by executing JS code is the
<button>
Second best would be a
<div>
or at last resort a
<span>
if you really need your action to be in-line, which would be a bit unorthodox from a UX point of view.
At any rate : give your clickable element an id attribute, then, in a distinct and separate .js file, define what it does like so :
document.getElementById('thatId').addEventListener('click', function(e){
     /* 
     * Your code goes here.
     * The event argument e holds all what you need to know about
     * what was clicked.
     */
});
In the "Related" side bar, I see this very relevant thread. Read it seriously.