Jquery set variable input field value
<p>My HTML:</p>

<pre><code>&lt;input id="penge" /&gt;
&lt;input type="button" onclick="javascript: paymentwindow.open()" value="BETAL" id="betal" /&gt;
</code></pre>

<p>My jQuery:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
var penge = $("#penge").val();


            paymentwindow = new PaymentWindow({
                         'amount': penge,
                         'currency': "DKK",
                         'language': "1",
                         'orderid': "155",
                         'callbackurl': "http://localhost:3000/"
            });
});
&lt;/script&gt;
</code></pre>

<p>The variable is undefined. I want to set the variable penge when the betal button is clicked.</p>

<p>UPDATE:</p>

<pre><code>&lt;script type="text/javascript"&gt;
$(document).ready(function(){
var penge;
$('#betal').click(function(){
    penge = $("#penge").val();
    paymentwindow.open();
});




            paymentwindow = new PaymentWindow({
                         'amount': penge,
                         'currency': "DKK",
                         'language': "1",
                         'orderid': "155",
                         'callbackurl': "http://localhost:3000/"
            });
});
&lt;/script&gt;
</code></pre>

<p>Penge is undefined. I have also removed the onclick js for the betal button.</p>
