473,574 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use onClick to change CF values

139 New Member
Hi,

I have created several queries which produce the same data based on a slightly difference set of variables:

Expand|Select|Wrap|Line Numbers
  1. <cfquery name="KWBand1S" dbtype="query">
  2.         select         ClientFK,
  3.                 ResponseLevelFK,
  4.                 PowerRating,
  5.                 WORecDate,
  6.                 ActualCompDate,
  7.                 QuoteACDate,
  8.                 QuotePDate    
  9.         from         getPumpsDate
  10.         where        ResponseLevelFK like 'Standard'
  11.                 and (PowerRating >0
  12.                 and PowerRating <=2.9)
  13.         </cfquery>
The only variable that changes is the Power Rating - it has various ranges and I just created a query for each one.

The output gets mashed up so that the number of records are counted and divided by a count of the days in the date range to produce a number N:

Expand|Select|Wrap|Line Numbers
  1. <cfset intDayTotal = 0>
  2.         <cfloop query="KWBand1S">
  3.         <cfset dtFrom = #WORecDate# />
  4.         <cfset dtTo = #ActualCompDate# />
  5.         <cfset ctDays = DateDiff ("d", dtFrom, dtTo)>
  6.         <cfset intDayTotal = intDayTotal + ctDays>
  7.         </cfloop>
  8.         <cfset RecCount = KWBand1S.RecordCount>
  9.             <cfif RecCount NEQ 0>
  10.             <cfset KWBand1SD = intDayTotal/RecCount>
  11.             <cfoutput>#numberFormat(KWBand1SD, "___._")#</cfoutput>
  12.  
  13.             <cfelse>
  14.             -
  15.             </cfif>
Which all works. But now I need to output the records in a table - fine, except that I have 12 different query sets to work from.

Is there anyway to have the source of my output table as a variable whose value is changed when the user clicks on the number N - ie showing the records in that query set? I was thinking that an onclick event might change the variable value, but don't know how.

Thanks
Neil
Jul 20 '09 #1
21 8317
acoder
16,027 Recognized Expert Moderator MVP
This would be more of a JavaScript question, but you could use the same query using <cfif> to decide which power rating to use.

Do you want only one number set to be displayed at a time, or would the whole lot do? Also, does the change have to happen instantly or is a page unload/reload not a problem?
Jul 20 '09 #2
ndeeley
139 New Member
hi Acoder,

how would I achieve this? i only want it to display one number change at a time, but obviously want to give the user the choice of changing it (whether clicking on the number or selecting the criteria from a drop down list box).

I need instantaneous update really.
Jul 20 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
You have at least two choices:
1. Load all the data into JavaScript data structures, e.g. arrays to use to update the table. Use Coldfusion to generate the JavaScript code.
2. Use Ajax. Make a Http request to a Coldfusion page which gets the correct data for the passed parameter.

Which one would you be more comfortable with?

Note: Coldfusion 8 has a few Ajax tags, but I personally haven't really looked into them, because I'm quite comfortable with JavaScript/Ajax.
Jul 20 '09 #4
ndeeley
139 New Member
The first really, as I`m using a company server that only runs CF5 and no ajax (as far as I am aware).
Jul 20 '09 #5
ndeeley
139 New Member
The only other thing i was thinking of doing was generating a table from each query, then hiding it until the user clicks on a number, which would show the table, but I`m guessing that a javascript question!
Jul 20 '09 #6
acoder
16,027 Recognized Expert Moderator MVP
Yes, that would be another option, but you would need to use Coldfusion to generate it.

Note that Ajax support is more to do with the browser rather than the version of Coldfusion, so it's still an option for you.
Jul 20 '09 #7
ndeeley
139 New Member
Thanks acoder - what I've done is generate all the tables then just hidden them using .css, using a javascript function to open them:

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. //here you place the ids of every element you want.
  3. var ids=new Array('s1','s2','s3','s4','s5','s6','c1','c2','c3','c4','c5','c6');
  4.  
  5. function switchid(id){    
  6.     hideallids();
  7.     showdiv(id);
  8. }
  9.  
  10. function hideallids(){
  11.     //loop through the array and hide each element by id
  12.     for (var i=0;i<ids.length;i++){
  13.         hidediv(ids[i]);
  14.     }          
  15. }
  16.  
  17. function hidediv(id) {
  18.     //safe function to hide an element with a specified id
  19.     if (document.getElementById) { // DOM3 = IE5, NS6
  20.         document.getElementById(id).style.display = 'none';
  21.     }
  22.     else {
  23.         if (document.layers) { // Netscape 4
  24.             document.id.display = 'none';
  25.         }
  26.         else { // IE 4
  27.             document.all.id.style.display = 'none';
  28.         }
  29.     }
  30. }
  31.  
  32. function showdiv(id) {
  33.     //safe function to show an element with a specified id
  34.  
  35.     if (document.getElementById) { // DOM3 = IE5, NS6
  36.         document.getElementById(id).style.display = 'block';
  37.     }
  38.     else {
  39.         if (document.layers) { // Netscape 4
  40.             document.id.display = 'block';
  41.         }
  42.         else { // IE 4
  43.             document.all.id.style.display = 'block';
  44.         }
  45.     }
  46. }
  47. </script>
Where the div has the ID shown in the function.

One other thing tho - if I include in my table another link (a particular order number for example) can I use CF to open that link, carrying the order number variable to another bit of cfm script? (in this case a script that shows the order details for that number, which I already have).

Thanks for your help
Neil
Jul 21 '09 #8
acoder
16,027 Recognized Expert Moderator MVP
That code should work, though the code is badly out of date.
@ndeeley
Either use the same method, i.e. keep hidden initially and show with JavaScript, or use Ajax to show only the ones required as and when needed. The advantage of the first way is that you've already got something similar working, but if there's a lot of stuff, it may affect page load.
Jul 21 '09 #9
ndeeley
139 New Member
Yes, I didn't write it - I found it on the web, and it workd, so I used it. I haven't done any training in Javascript. Unfortunately I`m in one of those jobs where you get trained on something, use it for a while, and then not for 12 months...

Thanks for your comments - I'll give it a go!

Cheers
Neil
Jul 22 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
60092
by: Zalek Bloom | last post by:
Hello, Here is my problem: I am displaying to a user a row of buttons. Depending on which button user presses, I want to go to a different URL and to give a different value to a hidden variable. My code is: <FORM NAME=FORM1 ACTION=""> <input type="button" name="B1" onclick="ModC('1')">
8
67455
by: KS | last post by:
Just to show some code to show the consept. <img id="date" onclick="javascript:show_calendar();" src="/PlexSysWeb/images/show-calendar.gif" width=20 height=18 border=0> What i want the javascript to do is change the onclick value of the <IMG> tag above, by calling the test function from the same webpage by onclick on a button.
10
3614
by: WindAndWaves | last post by:
Hi Gurus I have the following code: function CI(ImgN, Alt){ if( document.getElementById && document.getElementById('il') ){ var d=document.getElementById('il');
1
2164
by: Dark Magician | last post by:
Comrades: Am trying to build a UI widget. I'm sure part of the problem is proper variable scope or object reference, and part of the problem may be the way I'm calling the function, but, here goes. Part I. Consider: A B C D M E F G H N O
1
1711
by: Ben | last post by:
Hi, I have a number of images whose src's are changed when a button is pressed. At the moment the href is also changed and the images are opened. However I have a function which opens the images in their own windows. I want to run this for each image using the onClick event of the image. I have all the images and links stored in there...
5
17681
by: johnsuth | last post by:
I want to produce a trivial demonstration of dynamic modification. I thought that pressing a button might change its color. I studied O'Reillys books and successfully created the button with a fancy style, but the onclick fails to do anything no matter what permutation of parameters I try. <input type=button...
2
3061
by: gakman_2006 | last post by:
I am trying to get an onclick event to pass some values to a function to display in an alert box for now. I can get it sort of working but now the way I need it. I will be changing the alert in the function to open in a new window after I get the onclick call working properly. I read from an array to get my names then I want to click on the...
12
9538
by: Andrew C | last post by:
Hi, folks. I've recently been doing a few simple tests and experiments. As a result, I've noticed that, in dealing with 'onclick', IE seems less able than Firefox to keep up with rapid clicking. In fact, Firefox seems to be able to keep up with me no matter how rapidly I click, whereas IE... well, doesn't! The following snippet of code...
1
4076
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score...
0
7832
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7843
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8129
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6498
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5643
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5331
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3768
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3785
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2262
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.