MrM
MrM

Reputation: 21999

How do I concatenate two textboxes in JQuery?

I am adding rows to my table and the address will be a concatenation of Street, City, State, and Zip. Right now I have this.

    $tr.find('.name').text($('#txtPropName').val());
    $tr.find('.address').text($('#txtPropAddress', ", ", '#txtPropCity', " ", '#txtPropState', " ", '#txtPropZip').val());
    $tr.find('.phone').text($('#txtPropHPhone' + "<br/>" + '#txtPropWPhone').val());   

No luck on either phone or address. Any ideas?

Upvotes: 1

Views: 3011

Answers (2)

Paul Alexander
Paul Alexander

Reputation: 32377

The code

$('#txtPropHPhone' + "<br/>" + '#txtPropWPhone')

is basically telling jQuery to look for an element named '#txtPropHPhone<br/>#txtPropWPhone'.

You'll need to break out the individual elements into separate jQuery requests.

$('#txtPropHPhone').val() + '<br/>' + $(txtPropWPhone').val();

Upvotes: 3

easement
easement

Reputation: 6139

Does it work if you get the val()s seperately?

$tr.find('.phone').text($('#txtPropHPhone').val() + "<br/>" + $('#txtPropWPhone').val());

Upvotes: 0

Related Questions