Hi, .. '
Please help, I am using a javascript which is shown below to add a row dynamically to my table data in MVC view.Here I want to use 4 dropdown lists which should fetch data from database and show in the view.
$("#myButton").click(function () {
// Create elements dynamically
var newRow = '' + ';
'@Html.DropDownList("SupplierId", String.Empty) ' +
'@Html.DropDownList("SKU", String.Empty) ' +
// Add the new dynamic row after the last row
$('#myTable tr:last').after(newRow);
//var newRow1=''+' ';'+'
});
// Bind the click event, to the table rows
// New way (jQuery 1.7+) - .on(events, selector, handler)
$('#myTable').on('click', 'tr', function (event) {
// Add or Remove the class on clicking the table row
$(this).toggleClass('myClass');
});
While running my application I am getting error, "SCRIPT1015 error;Unterminated string constant" at
'
'
The code showing error while running is shown below:
$("#myButton").click(function () {
// Create elements dynamically
var newRow = '
'
'
'
'
'
'
'
'
'
'
$('#myTable tr:last').after(newRow);
//var newRow1='
});
Any help will be appreciated.Thanks in advance.
Dhirendra MisraPosted Jan 6, 2014, 3:12 AM