Javascript Increment ++ and Decrement --
<p>In the following snippet input_Position decrements from 11 to 10 but sometime it will not decrement any further. I have tried to use <code>input_Position = input_Position - 1;</code> instead but it does not work. I can not see any reason why this does not work, and I must be missing something obvious!</p>

<pre><code>switch(event.which) {
    case 37:
        kp_Count++;

        if (input_Position &lt;= 1){
            input_Position = 1;
        } else {
            input_Position--;
        }

        var msg = $("&lt;p&gt;Handler for .keypress(37) left arrow called " + kp_Count + " time(s) - cursor position " + input_Position + ".&lt;/P&gt;");
        $("#msgprint").html(msg.html());
        break;
}
</code></pre>

<hr>

<p>Sometimes the same code decrements and increments smoothly and outputs correctly, but when I refresh the page and try again it does not work. I do not think that cause is the use of increment and decrement, but what else could be causing the problem?</p>

<p>Here is a little more code that may help find the problem:</p>

<pre><code>// Event binding
$("#date").bind("keydown", date_Key_Cntrl ); 

function date_Key_Cntrl(event) {
    switch(event.which) {
        case 37:
           ....
           ....
        case 39:
           ...
        case 8:
           ....
        case 35:
           ....
        case 36:
        default:
    }
}
</code></pre>
