Newbie
Newbie

Reputation: 249

add new row to a table using jquery

when I try to add a new row the fields in a row are as follows

$('#building').val()   $('#floor').val()

But I want to display the value it contains.

jQuery:

var newRow =
    $("<tr><td>$('#building').val()</td><td>$('#floor').val()</td><td></td></tr>");     
    $('#building-table').append(newRow);

html:

<select id="building" name="building" >
<option>1</option>
<option>2</option>
</select>
<input id="floor" name="floor" type="text" />
<input type="button" id="save" value="save" />

Can anyone help me on this?

Upvotes: 0

Views: 3274

Answers (1)

David B&#233;langer
David B&#233;langer

Reputation: 7438

Maybe this ?

var newRow = "<tr><td>"+$('#building').val()+"</td><td>"+$('#floor').val()+"</td><td></td></tr>";
$('#building-table').append(newRow);

Upvotes: 3

Related Questions