SlimJim
SlimJim

Reputation: 377

positioning button in table

I'm dynamically creating a table row, as below, with a "Delete" button inside the last table cell, but when rendered, the Delete button doesn't land neatly in the table where it should be. Any ideas?

    strAppend = '<tr>' +
                    '<td id="SUBJ_'+idNum+'" class="td-SUBJ_'+idNum+'"><input type="text" class="SUBJ" value="Elective" name="SUBJ"> </td>' +
                    '<td id="REQUIRED_'+idNum+'" class="td-REQUIRED"><input type="checkbox" value="1" maxlength="40"> </td>' +
                    '<td id="DELETED_'+idNum+'" class="td-DELETED"><button id="DELETE_"'+idNum+'" class="DELETE">Del</button></td>' +
                    '<td><input value="Test"></td>' +
                '</tr>'

    //Add row
    $j("tbody > tr:last").prev().before(strAppend);

Upvotes: 0

Views: 30

Answers (1)

Robbert
Robbert

Reputation: 6582

You are closing your quote too early

'<td id="DELETED_'+idNum+'" class="td-DELETED"><button id="DELETE_"'+idNum+'" class="DELETE">Del</button></td>' +

Will result in something like this

<td id="DELETED_5" class="td-DELETED"><button id="DELETE_"5" class="DELETE">Del</button></td>

Get rid of the extra quote in the button definition

'<td id="DELETED_'+idNum+'" class="td-DELETED"><button id="DELETE_'+idNum+'" class="DELETE">Del</button></td>' +

Upvotes: 2

Related Questions