0

I know this sounds backwards... yes, I want to know how to create a cfquery object from an already created HTML table. Here's my use case:

1) I've created a cfquery object and have some data

2) I've looped over the cfquery and created the HTML table

3) Now I've run some custom javascript to add more columns to the HTML table (e.g., my original cfquery had week number and I wanted to add Week Day monday-based so I did that)

4) So now I have an HTML table that is different from my cfquery object and I want to create an export of the data in the HTML table using some cfscript I already have but the cfscript takes in cfquery

Now I'm stuck at this so called step 4. What's the best way to create a cfquery object from HTML table sort of reverse engineering that back into a cfquery object?

Krusaderjake
  • 479
  • 1
  • 7
  • 19
  • Whatever you did on the client is javascript, do on the server with coldfusion. – Dan Bracuk Oct 06 '18 at 02:42
  • 1
    You could do this by snatching up the DOM and passing it to the server and using the QueryNew() and sister functions - but it's almost certainly the wrong approach. What is it that your client script doing that you are having difficulty with doing server-side and we could help with that instead. For example, you can do your dates with full names with dateFormat( yourDate , 'dddd') – Nate Oct 08 '18 at 17:22
  • Yes, in this use case I am trying to just add week day to the cfquery object. Good call on just doing this server side instead of adding more code to get the HTML table portion of the DOM passed back to server side coldfusion. I stumbled across a good tutorial on this here related specifically to get week day from year, week number input https://www.bennadel.com/blog/719-ask-ben-getting-the-date-based-on-the-year-and-week-in-coldfusion.htm – Krusaderjake Oct 08 '18 at 19:25
  • @Nate That's what I was trying to do, was pass an ajax call with URL parameters/posting form data with the necessary data back to the server and then was going to use the QueryNew() function(s) once I had the data back on server side. I couldn't quite figure out how to get the data from the ajax call though. Seems like a lot of extra work to try to get HTML data back to coldfusion variables. – Krusaderjake Oct 08 '18 at 19:30

1 Answers1

0

Doing all of that server side is the way to go. But answering the original question just for giggles...

What you could do is serialize the table data into json format. Convert a HTML table data into a JSON object in jQuery Send that to CF with a POST operation.

Then deserialize the post data into a query object. https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-c-d/DeserializeJSON.html

Jules
  • 1,941
  • 15
  • 18