Comparing two input fields - What am I doing wrong?
<p>Forgive me but I'm just starting to learn Javascript. I'm trying to get the sum of two input fields, and I'd like to update the result "live" so to speak, on every keyup event.</p>

<p>At the moment the result field just disappears when values are entered into the input fields.</p>

<p>What am I doing wrong?</p>

<p>Thank you so much,</p>

<p>Peter</p>

<p>edit: how stupid of me, I forgot to post the code</p>

<p><a href="http://jsfiddle.net/u7VwP/" rel="nofollow">http://jsfiddle.net/u7VwP/</a></p>

<pre><code>var inputFirst = $('#first'),
    inputSecond = $('#second'),
    inputFirstVal = inputFirst.val(),
    inputSecondVal = inputSecond.val();

function getResult(first, second) {
 var result = first + second;
 $('p#result').text(result);
};


inputFirst.on('keyup', function() {
 getResult(inputFirstVal, inputSecondVal);
});
inputSecond.on('keyup', function() {
 getResult(inputFirstVal, inputSecondVal);
});​
</code></pre>
