Highlighted

Would like to build a list of rows from table, and then select one row to update

New Here ,
Apr 22, 2016

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

TOPICS
Getting started

Views

407

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Would like to build a list of rows from table, and then select one row to update

New Here ,
Apr 22, 2016

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

TOPICS
Getting started

Views

408

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 22, 2016 0
Adobe Community Professional ,
Apr 22, 2016

Copy link to clipboard

Copied

There is a cool new attribute in HTML 5:

<td contenteditable="true"></td>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 22, 2016 0
A___ LATEST
Participant ,
May 20, 2016

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:

  • Have a ColdFusion template that will do the database manipulation
  • onClick() a table row, make an AJAX call (see sample below) to the ColdFusion template
  • ColdFusion will then delete or update the database record (the row id comes in handy in your WHERE clause)

<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>

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 20, 2016 0