• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Apr 22, 2016 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

483

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
community guidelines
Community Expert ,
Apr 22, 2016 Apr 22, 2016

Copy link to clipboard

Copied

There is a cool new attribute in HTML 5:

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

Votes

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
community guidelines
Participant ,
May 20, 2016 May 20, 2016

Copy link to clipboard

Copied

LATEST

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>

Votes

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
community guidelines
Resources
Documentation