 <p>Please update your updateInput with following code</p> <pre><code>function updateInput(ish){ cc2=ish; } </code></pre> <p>This will assign the value of your input to cc2 var. So on each change in input will make cc2 to holds the latest value.</p>