0

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?

1
  • 1
    You have to concatenate the return values of those functions with your HTML string, if you simply enclose it in quotes then it'll be treated as a string. JS behaves differently than PHP if you have experience with it. Commented Aug 31, 2012 at 19:07

1 Answer 1

3

Maybe this ?

var newRow = "<tr><td>"+$('#building').val()+"</td><td>"+$('#floor').val()+"</td><td></td></tr>";
$('#building-table').append(newRow);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.