Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7575875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:47:09+00:00 2026-05-30T16:47:09+00:00

I have a series of table rows like this: <cfloop query=qryPlayer> (…snip…) <input data-playerid=#PlayerID#

  • 0

I have a series of table rows like this:

<cfloop query="qryPlayer">
   (...snip...)
   <input data-playerid="#PlayerID#" name="PlayerSort" value="#PlayerSort#">
   (...snip...)
</cfloop>

At the bottom of the form, I have a single field:

<input type="hidden" name="PlayerIDs"> <!--- Populated by js --->

Whenever the user changes a value in any row, I populate PlayerIDs with a list of the primary keys associated with the fields that needs to be updated:

$('input[name=PlayerSort]').change(function() {
    $('input[name=Save]').show();
    var arrPlayerID = [];
    $('input[name=PlayerSort]').each(function() {
        if ($(this).val()) {
            arrPlayerID.push($(this).data('playerid'));
        }
    });
    $('input[name=PlayerIDs]').val(arrPlayerID.join(','));
});

Then when the user presses the Save button, I update all the fields that have values in them.

Q: Is that the right thing for me to be doing? It works, but have I forgotten some fundamental way of handling a form submit?

BTW, the client doesn’t want it to be AJAXified because he wants to give the user the ability to press reset and start over again. So, enter a bunch of values, click Save, and have ColdFusion update all the PlayerSort values associated with form.PlayerIDs.

<cfloop list="#form.PlayerIDs#" index="local.PlayerID">
   <cfset local.Index = local.Index + 1>
   UPDATE dbo.Player SET
   PlayerSort = <cfqueryparam cfsqltype="cf_sql_integer" value="#ListGetAt(form.PlayerSort,local.Index)#">
   WHERE PlayerID = <cfqueryparam cfsqltype="cf_sql_integer" value="#local.PlayerID#">;
</cfloop>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:47:11+00:00Added an answer on May 30, 2026 at 4:47 pm

    I think your approach is fine. It could, however, be done without JavaScript which would reduce and simplify your code a bit as well as ensure it works on the odd chance that the user has JavaScript disabled.

    Use this for your form code:

     <cfloop query="qryPlayer">
        (...snip...)
        <input name="PlayerSort_#PlayerID#" value="#PlayerSort#">
        (...snip...)
     </cfloop>
    

    Then your action code would be this:

     <cfloop collection="#Form#" item="field">
        <cfif ListLen(field,"_") IS 2 AND ListFirst(field,"_") IS "PlayerSort">
            <cfquery datasource="YourDatasource">
            UPDATE  dbo.Player
            SET     PlayerSort = <cfqueryparam cfsqltype="cf_sql_integer" value="#Form[field]#">
            WHERE   PlayerID = <cfqueryparam cfsqltype="cf_sql_integer" value="#ListLast(field,'_')#">
            </cfquery>
        </cfif>
     </cfloop>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table of time-series data of which I need to find all
I have a table of data which represents a series of events that persons
I have a series of select boxes within a table like so: <tr> <td><select></select></td>
I have a query like this: SELECT A, B, C, CASE WHEN 1 =
I have a table with arbitrary columns and rows. This fact is irrelevant though
I store time-series simulation results in PostgreSQL. The db schema is like this. table
I have a series of NSFetchedResultsControllers powering some table views, and their performance on
I have a table that represents a series of matches between ids from another
Imagine I have a table which stores a series of sparse vectors. A sparse
I have a series of tables that contain data I want to full text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.