Finx
Finx

Reputation: 61

jquery read and display in text field

I have a price calculator on my website. I would like jquery to pick the value on one box and send it to the other box in real time.

<form>
How much do you want to spend <input type="text" id="pricein" /><br />
This is how much you will spend<input type="text" id="priceout"/>
</form>

anybody know how this can be accomplished with jquery? This sounds like it might be easy but I'm learning it all slow but I'm learning. Thanks!

Upvotes: 2

Views: 172

Answers (3)

james31rock
james31rock

Reputation: 2705

use keyup

$('#pricein').bind('keyup', function() 
    { 
        $('#priceout').val($(this).val()); 
    });​

JSFIDDLE

Upvotes: 1

kei
kei

Reputation: 20481

$("#pricein").keyup(function() {
    $("#priceout").val($("#pricein").val());
});​

DEMO

Upvotes: 7

peacemaker
peacemaker

Reputation: 2591

You need the val() function:

var price = $('#pricein').val()

and to set the value:

$('#priceout').val(newValue);

You can read the documentation here

Upvotes: 1

Related Questions