I'm editing a previous coworkers code so I don't know 100% how it works. It is written in Javascript and ASP. Here is the current code
<script>
    var sessionDone = 0;
    <% if session(ReturnSessionID()) = 1 then %>
        sessionDone = 1;
    <% endif %>
</script>
and then there is some html with links, like this:
<a href='#'>link</a>
What I want is this:
<script>
    var sessionDone = 0;
    var counter = 0;
    $('a').click( function() {
        sessionDone = 1;
        if (counter == 3) {
            <% session(ReturnSessionID()) = 1 %>
        } else {
            counter += 1;
        }
    });
</script> 
When I do this, the line
<% session(ReturnSessionID()) = 1 %>
automatically gets run even if the if statement isn't true and even if I did not click a link. How do I make the link only get executed when counter is 3?
Note: I do not know ASP and I don't really need to learn it, this is the only time I will be using it.
 
    