Solved

running coldfusion code

Posted on 2000-03-14
5
348 Views
Last Modified: 2013-12-24
I am new to coldfusion and html althouth I am learning fast and getting by.
 Can anybody tell me how to run a section of cold fusion code on the ONCLICK event of a button and then go to an href location. Do I have to run code in another template or can I embed the code in a function or procedure within the same template??

For Example, I have a grid with data from a table with contains bacthes of transactions. My grid displays Batchid, Open date, close date, status, etc...
Under my grid, I have 3 buttons View batch, Delete batch, Close batch.
When My viewbatch button is clicked, I want to go to another page which will display the batch contents using the batchid of the selected batch(that was simple). But my problem is for the other two buttons. For the delete, I want to send a delete sql statement to the table for the selected batch and refresh(point back to) same page. For close, I want to send an update query to the table for the selected batch and return to the same page.

I am an experieced vb programmer and I think this is what's causing all of my problems.
Should I think of redesigning the process (layout of GUI) or is this an okay  way of doing it??
Is this a javascipt thing or can it be done using coldfusion tags alone??
I would really appreciate any feedback.
Thanks,
Alex Campomanes
0
Comment
Question by:acampoma
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
dlewis9 earned 100 total points
ID: 2620595
I'm not aware of any way to run Cold Fusion code after a page has been loaded like you can do with Javascript.  Cold Fusion obviously runs on the server while Javascript runs locally.  However, like you suggested, you can put it in a seperate template.  You then would go to that location within the ONCLICK event for your button, run your code, and then use whatever (CFLOCATION perhaps) to get back to the original page.  The code would run behind the scenes and it would look like just a simple page refresh when the button is clicked, as long as your SQL statement runs quickly.

I don't think there's anything wrong with the way you are doing it..I've done several things in the same manner, but with just using hyperlinks instead of buttons, so no Javascript is required.  Web programming is a different animal and you just have to change the thought process sometimes..
0
 
LVL 6

Author Comment

by:acampoma
ID: 2624478
I'll accept it but it would be helpfull if you could tell me how to obtain the value selected in the grid and pass it on to the next form as a parameter.
Thanks,
Alex
0
 
LVL 2

Expert Comment

by:dlewis9
ID: 2630545
My experience with CFGRID is that you make all your changes up front (edits, insert rows, delete rows) and then you submit the whole thing and Cold Fusion makes the appropriate changes to the database.  (You can add the insert and delete buttons to the bottom of the GRID through CFGRID's attributes).  I'm not sure that you can find out what row is selected, but I'll see what I can find out.  If you turn on debugging and submit the grid through a cfform, you can see all of the FORM variables..that may help.

I use the grid a little bit, but have resorted back to HTML tables in some cases.  From there, I just use hyperlinks to my processing page and pass a URL variable of the ID of the record that was clicked on (this would be the row that was selected if using a grid)..
0
 
LVL 2

Expert Comment

by:dlewis9
ID: 2635386
Checked around a little more and don't see a way to determine the selected row after you post the grid..

However, you can make one (or more) of the columns in the grid a hyperlink with a key value and it will take you to another page and will append the key value to the URL for your use.  In this manner, you could click on a batch value in the grid and it would take you to the "view" page for that batch, and from there, have two buttons for close and delete.  Those functions would be easy at that point since you know which record to work with.

Here's a modified example of something I'm using..this grid has two columns, 1 non-displayed key column, and one other column that uses the key column in the HREFKEY attribute of the CFGRIDCOLUMN.

<CFGRID NAME="outputgrid" HEIGHT="500" WIDTH="625" QUERY="qry_getloadinfo" INSERT="No" DELETE="No" SORT="Yes" BOLD="No" ITALIC="No" APPENDKEY="Yes" HIGHLIGHTHREF="Yes" GRIDDATAALIGN="LEFT" GRIDLINES="Yes" ROWHEADERS="No" ROWHEADERALIGN="LEFT" ROWHEADERITALIC="No" ROWHEADERBOLD="No" COLHEADERS="Yes" COLHEADERALIGN="LEFT" COLHEADERITALIC="No" COLHEADERBOLD="No" SELECTMODE="SINGLE" PICTUREBAR="No">
      <CFGRIDCOLUMN NAME="identity_key" HEADER="Key" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" SELECT="No" DISPLAY="No" HEADERBOLD="No" HEADERITALIC="No">
      <CFGRIDCOLUMN NAME="is_identifier" HEADER="IS Identifier" HEADERALIGN="LEFT" DATAALIGN="LEFT" BOLD="No" ITALIC="No" HREF="../../secure/is/akey/editentry.cfm" HREFKEY="identity_key" SELECT="Yes" DISPLAY="Yes" HEADERBOLD="No" HEADERITALIC="No">
</CFGRID>

when a row is clicked, it takes you to the specified address with a URL parameter called CFGRIDKEY attached (such as ../../secure/is/akey/editentry.cfm?CFGRIDKEY=149)

Hope that helps?!
0
 
LVL 6

Author Comment

by:acampoma
ID: 2641827
Thank You very much!!!
You have been very helpful.
Alex Campomanes
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need to Configure Debug Diag 2.2 for IIS 7.5 to capture dump files 1 60
Use System DSN 6 83
Autoresponder for Whole Domain in Plesk/Cpanel 2 68
Grunt No Clean Targets 6 100
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now