I want to add data to a selective cell of a table. I wrote this code in JavaScript.
var rowIndex = 10; var colIndex = 5; var dateTable = document.getElementById('timeTable'); dateTable.rows[0]rows[rowIndex].cells[0]cells[colIndex].innerHTML = "Su"; I wanted to use the same concept in jQuery as:
$('input[name=add_button]').click(function(e) { var dateTable = document.getElementById('timeTable'); var rowIndex = $('[name=days]').val(); var colIndex = $('[name=times]').val(); var text = $('input[name = text]').val(); dateTable.rows[rowIndex].cells[colIndex].innerHTML = text; e.preventDefault(); }); My problem is: preventDefault() method should prevent my form to be submitted. It is not preventing form submission. If I remove the dateTable.rows[rowIndex].cells[colIndex].innerHTML = text; line, the form is not submitted. I think there is some problem with this particular line. Please help me sorting this. If there is better option available in jQuery please tell me. I shall be able to use the colIndex and rowIndex to find the position of the cell.
Thanks