Copy link to clipboard
Copied
I just started working with ColdFusion this week.
I have been experimenting with adding, changing, deleting, and viewing records in a small test database table.
I would like to be able to display a list of rows and then select one row to change.
I have been able to create a small HTML table to show the rows, but I am not sure that this is the best way to do this and I cannot figure out how to select a row from this HTML table.
Perhaps someone could share an example or point me to an example on the internet.
Thanks,
Brad
Copy link to clipboard
Copied
There is a cool new attribute in HTML 5:
<td contenteditable="true"></td>
Copy link to clipboard
Copied
As pointed out by ACP, contenteditable is very useful for editing the content of an HTML element.
It is neat to then use AJAX plus ColdFusion to delete/update records on your database.
For example, to delete a database record when you click on the corresponding row of the HTML table:
<script>
$(".yourTableClass")
.on('click', 'tbody tr', function(){
// Assuming your first cell holds the database table PRIMARY KEY
// .eq(0) finds the first cell
var id = $(this).closest('tr').children().eq(0).text();
// Then delete that record on your database via AJAX, using the id you have picked up
$.ajax({
type: "...",
url: "...",
dataType: "...",
data: {
tablePrimaryKey: id,
... : ... ,
... : ...
},
success: function(result, textStatus, jqXHR) {
... ;
... ;
}
}) // End of ajax call
})
</script>