Sequential arithmetic operation in javascript
<p>I've a text input and user will write a string for example <code>10+20-10-2*2+4/2</code> and I want to do an arithmetic operation sequentially, which means I want to <code>(10+20)-(10)-(2)*(2)+(4)/(2)</code> and the result should be <code>20</code> according to above example.</p>

<p>In other words I want to do the arithmetic operation from the left, sequentially. Can anyone help me on this or may be some idea would be nice too. Thanks.</p>

<p><strong>Please ask me if need more information.</strong></p>

<pre><code>$('#calculation').on('blur', function(e){
    e.preventDefault();
    var pattern=/^[-*/+0-9]+$/;
    value=$(this).val();
    if(value.match(pattern))
    {

        $(this).closest('tr').find('span.error').html('');
        //$('#total').val(eval(value));
        // No idea what to do

    }
    else
    {
        $(this).closest('tr').find('span.error').html('Invalid character');
    }
});
</code></pre>
