I have output from a table that I want highlighted should a certain requirement not be met. I have it working fine for one section, but then when I use the code on a QofQ after an inner join of two tables, it doesn't work.
I can see when I dump the variables that they are correct and I know 100% that one of the companies contains no negative data so should display correctly but both companies are displaying in red.
I'm obviously not seeing something or does QofQ have limitations that are causing this ?
I'm still learning so please be kind :)
Queries :
<cfquery name="suppNeg" datasource="users">
SELECT companies.subID, companies.companyID, companies.suppName
, suppresult_old.companyID, suppresult_old.O18, suppresult_old.O19
, suppresult_old.O20, suppresult_old.O22, suppresult_old.WDPVC1
, suppresult_old.WDPVC2, quarterID
FROM suppresult_old INNER JOIN companies
ON suppresult_old.companyID=companies.companyID
WHERE quarterID = 8
AND companies.subID = #session.auth.companyID#
ORDER BY companies.suppName ASC
</cfquery>
<cfquery dbtype="query" name="subs">
SELECT DISTINCT suppName, companyID, subID
FROM suppNeg
ORDER BY suppName ASC
</cfquery>
<cfquery name="columntotals" datasource="users">
SELECT O18,O19,O20,O22, WDPVC1, WDPVC2
FROM suppresult_old INNER JOIN companies
ON suppresult_old.companyID=companies.companyID
WHERE quarterID = 8
AND companies.subID = #session.auth.companyID#
</cfquery>
<cfset O18Value = valueList(columntotals.O18) />
<cfset O18total = listToArray(O18Value) />
<cfset O19Value = valueList(columntotals.O19) />
<cfset O19total = listToArray(O19Value) />
<cfset O20Value = valueList(columntotals.O20) />
<cfset O20total = listToArray(O20Value) />
<cfset O22Value = valueList(columntotals.O22) />
<cfset O22total = listToArray(O22Value) />
<cfset WDPVC1Value = valueList(columntotals.WDPVC1) />
<cfset WDPVC1total = listToArray(WDPVC1Value) />
<cfset WDPVC2Value = valueList(columntotals.WDPVC2) />
<cfset WDPVC2total = listToArray(WDPVC2Value) />
<cfquery name="suppliers" datasource="users">
SELECT suppName, companyID, subID
FROM companies
WHERE subID=#session.auth.companyID#
ORDER BY suppName ASC
</cfquery>
Output :
<cfoutput query="subs">
<div class="container" width="1100">
<div class="row">
<a href="2tierReport.cfm?quarterID=8&companyID=#companyID#">
<cfif (arraysum(O18total)) LT 0>
<div class ="col-sm-4 supphighlight1">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong></a>
</h4>
</div>
</a>
<a href="2tierReport.cfm?quarterID=8&companyID=#companyID#">
<cfelseif (arraysum(O19total)) LT 0>
<div class ="col-sm-4 supphighlight1">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong>
</h4>
</div>
</a>
<a href="2tierReport.cfm?quarterID=8&companyID=#companyID#">
<cfelseif (arraysum(O20total)) LT 0>
<div class ="col-sm-4 supphighlight1">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong>
</h4>
</div>
</a>
<a href="2tierReport.cfm?quarterID=8&companyID=#companyID#">
<cfelseif (arraysum(O22total)) lt 0>
<div class ="col-sm-4 supphighlight1">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong>
</h4>
</div>
</a>
<a href="2tierReport.cfm?quarterID=8&companyID=#companyID#">
<cfelseif (arraysum(WDPVC1total)) LT 0>
<div class ="col-sm-4 supphighlight1">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong>
</h4>
</div>
</a>
<a href="2tierReport.cfm?quarterID=8&companyID=#companyID#">
<cfelseif (arraysum(WDPVC2total)) LT 0>
<div class ="col-sm-4 supphighlight1">
<h4>
<span class="glyphicon glyphicon-exclamation-sign" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong>
</h4>
</div>
</a>
<cfelse>
<a href="suppReports_admin.cfm?quarterID=8&companyID=#companyID#">
<div class ="col-sm-4 supphighlight">
<h4>
<span class="glyphicon glyphicon-ok-circle" style="color:##ffffff; font-size: 32px; vertical-align: middle;" aria-hidden="true"></span><strong> #subs.suppName#</strong>
</h4>
</div>
</a>
....
That's a lot to digest, without any data samples, but I'll take a stab at it :) I think the problem is that the code is comparing apples and oranges. The "sub" query contains the details for individual companies and subId's. (I've no idea what the real data looks like, so the samples below are just for illustration)
However, the cfif comparisons calculate the overall total for all companies and subId's. So if the overall total for O20 (O18, etc..) is negative, then it'll be negative for every company in the cfoutput.
Runnable TryCF.com Example
If all you want is the totals, by companyId and subId, it's much easier to calculate that in SQL. Instead of all the ValueList(), ArraySum() and QoQ's, use the SQL aggregate function SUM(). I don't know which DBMS you're using, but something like this should work in most any database:
Note: I "guessed" that quarterID is a column in the suppresult_old table
<!--- NOT TESTED --->
<cfquery name="totalsByCompany" datasource="users">
SELECT companies.subID
, companies.companyID
, companies.suppName
, suppresult_old.quarterID
, SUM(suppresult_old.O18) AS O18Total
, SUM(suppresult_old.O19) AS O19Total
, SUM(suppresult_old.O20) AS O20Total
, SUM(suppresult_old.O22) AS O22Total
, SUM(suppresult_old.WDPVC1) AS WDPVC1Total
, SUM(suppresult_old.WDPVC2) AS WDPVC2Total
FROM suppresult_old
INNER JOIN companies ON suppresult_old.companyID=companies.companyID
WHERE suppresult_old.quarterID = 8
AND companies.subID= <cfqueryparam value="#session.auth.companyID#" cfsqltype="cf_sql_integer">
GROUP BY companies.subID
, companies.companyID
, companies.suppName
, suppresult_old.quarterID
ORDER BY companies.suppName ASC
</cfquery>
Then in your cfoutput, use the calculated SUM's:
<cfoutput query="totalsByCompany">
....
<cfif O18total LT 0> .... code here
<cfelseif O19total LT 0>.... code here
<cfelse> ...
</cfif>
</cfoutput>
Aside: If you're new to S.O., might want to take a gander at How to create a Minimal, Complete, and Verifiable example. Putting together (the smallest possible) self-contained example demonstrating the problem makes it a LOT easier for others to assist, and less likely the question will be closed as too broad :) Also, tools like https://trycf.com and https://sqlfiddle.com are great for sharing runnable examples.
Related
Habing this code for coldfusion but after trying couple of times, i am always ending up showing categories multiple times and images multiple times too, i tried using the group attribute but that it also not doing its work, not sure what is going wrong
here is my complete code
<cfparam name="url.mode" default="">
<cfquery name="ImagesCategories">
select * from rivereast_gallerycategories
</cfquery>
<div id="spacingorder" align="right"><cfoutput>#DateFormat(now(),'long')#</cfoutput></div>
<div class="row">
<div class="col-xs-12 col-sm-12">
<h2>View Gallery Contents</h2>
<div align="right"> </div>
<div align="center">
<cfset variables.newrow = False>
<table align="center" width="100%" cellpadding="1" cellspacing="5" class="borderspacing">
<tr>
<cfif ImagesCategories.recordcount>
<cfoutput query="ImagesCategories">
#gallerycategory#
<cfquery name="filesListings">
select c.galleryCatID,c.ImageID,c.ImageName as name,c.updatedon
from rivereast_gallery c
order by updatedon desc
</cfquery>
<cfloop query="filesListings">
<cfif variables.newrow EQ true>
<tr>
</cfif>
<td height="30" valign="middle">
<div id="previewArea">
<cfset filename = Listlast(filesListings.name,'~')>
<img src="#request.weburl#uploads/#filename#" class="img-fluid"><br>
<input type="checkbox" class="ImagesDelete" name="delItems" data-id="#filesListings.imageID#"> Delete #filesListings.currentRow#
</div>
</td>
<cfif filesListings.currentRow MOD 5 EQ 0>
</tr>
<cfset variables.newrow = true>
<cfelse>
<cfset variables.newrow = false>
</cfif>
</cfloop>
</cfoutput>
<cfelse>
<td colspan="3" align="center"><h2>No Files Found</h2></td>
</cfif>
</tr>
</table>
<cfif filesListings.recordcount>
<div><input type="button" name="deleImages" id="delImages" class="button btn btn-info" value="Delete"></div>
</cfif>
</div>
</div>
</div>
what went wrong here
Hard to say without seeing the data, but it might be this. You are running this query inside a query loop.
<cfquery name="filesListings">
select c.galleryCatID,c.ImageID,c.ImageName as name,c.updatedon
from rivereast_gallery c
order by updatedon desc
</cfquery>
Note that it has no where clause. That could be the reason for seeing the same data more than once.
Assuming your database is somewhat normalized, the recommended fix is to just have one query that gets data from both tables at once. The sql would look something like this.
select JustTheFieldsYouNeed
from rivereast_gallerycategories c join rivereast_gallery g
on c.categoryID = g.categoryID
where some condition is met
I'd join the two queries
SELECT c.*, g.galleryCatID, g.ImageID, g.ImageName as name, g.updatedon
FROM rivereast_gallerycategories c, rivereast_gallery g
WHERE c.galleryCatID = g.galleryCatID
ORDER BY c.gallerycategory, g.ImageName
and then use
<cfoutput query="ImagesCategoriesAndFiles" group="category">
Cleaner code, less confusion.
See example here of how to use cfoutput for grouping record output: https://cfdocs.org/cfoutput
This script works fine. The issue I'm having is trying to get it to generate multiple barcodes per page. It will only generate the first one. the rest are blank images.
<cfoutput>
<cfset x = 0>
<cfloop index="price_tag" from="1" to="#arrayLen( session.tags )#">
<cfset x = x + 1>
<cfscript>
code128= createobject("java","com.lowagie.text.pdf.Barcode128");
code128.setCodeType(code128.CODE128);
/* Set the code to generate */
code128.setCode("#Session.tags[price_tag].itemnum#");
color = createobject("java","java.awt.Color");
image = code128.createAwtImage(color.black, color.white);
bufferedImage = createObject("java", "java.awt.image.BufferedImage");
bufferedImageType = bufferedImage.TYPE_BYTE_GRAY;
bufferedImage = bufferedImage.init(image.getWidth(JavaCast("null", "")),image.getHeight(JavaCast("null", "")), bufferedImageType);
graphics2D = bufferedImage.createGraphics();
graphics2D.drawImage(image,0,0,JavaCast("null", ""));
barcodeImage = imageNew(bufferedImage);
</cfscript>
<div style="margin:0px; padding:0px;">
<div style="font-size:42px; font-weight:bold; margin-bottom:0px; margin-right: 10px; margin-top: -5px;">#Session.tags[price_tag].item_name#</div>
<div style="font-size:32px; margin-bottom:0px; margin-top:-7px; margin-right: 10px;">#Session.tags[price_tag].item_brand#</div>
<div style="font-size:24px; margin-bottom:0px; margin-top:-7px;">#Session.tags[price_tag].item_unit_size# #Session.tags[price_tag].item_unit_type# </div>
<div style="font-size:120px; font-weight:bolder; margin-top:-55px; margin-right: 10px;" align="right">#DollarFormat(Session.tags[price_tag].item_retail)#</div>
<div style="font-size:30px; font-weight:bolder; margin-top:-30px; margin-right: 10px;" align="right"> #Session.tags[price_tag].item_sold_by#</div>
<div style="font-size:30px; margin-top:-35px; margin-left 10px;" align="left">#Session.tags[price_tag].itemnum#</div>
<div style=" position:absolute; margin-left: 10px; margin-top: 100px;"><cfimage action="writeToBrowser" source="#barcodeImage#" format="png" quality="1" width="180px" overwrite = "yes"></div>
</div>
<cfif #arrayLen( session.tags )# / #x# NEQ 1>
<cfdocumentitem type="pagebreak"/>
</cfif>
</cfloop>
</cfoutput>
It's probably because you are using action="writeToBrowser" in a loop within cfdocument. It's not going to a browser.
Try writing real files, then linking to them. I've done that and know it works. Make sure you use a distinct file name in that loop.
If you plan to run this routine over and over, it's safe to use the same file names. But in your code disable caching of the image src with a url var:
<cfoutput>
<img src="/media/cms/code-#price_tag#.png?rand=#randRange(0,1000)#" width="180"/>
</cfoutput>
Disclaimer, I'm a ColdFusion newbie...
I'm using Mura CMS 6, and I've got a question with regards to accessing a custom attribute.
My contentRenderer.cfc file has code for a Bootstrap Carousel. I'd like to be able to output the contents of a custom attribute on the file that the carousel is using, but I'm not entirely sure how to do that.
My custom attribute is named 'imageLink', but I have no idea how to get the current context to be able to output the contents of this attribute to the screen.
The following code is the code for the carousel (I didn't write it)
<cfsavecontent variable="local.str"><cfoutput>
<!--- BEGIN: Bootstrap Carousel --->
<!--- IMPORTANT: This will only output items that have associated images --->
<cfset local.feed = variables.$.getBean('feed').loadBy(name=arguments.feedName)>
<cfset local.iterator = local.feed.getIterator()>
<cfif local.feed.getIsNew()>
<div class="container">
<div class="alert alert-info alert-block">
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
<h4>Ooops!</h4>
The <strong>#HTMLEditFormat(arguments.feedName)#</strong> Content Collection/Local Index does not exist.
</div>
</div>
<cfelseif local.iterator.hasNext()>
<div id="#arguments.cssID#" class="carousel slide" data-interval="#arguments.interval#">
<!--- Indicators --->
<cfif arguments.showIndicators>
<ol class="carousel-indicators">
<cfset local.iterator.reset()>
<cfset local.idx = 0>
<cfloop condition="local.iterator.hasNext()">
<cfset local.item=iterator.next()>
<cfif ListFindNoCase('jpg,jpeg,gif,png', ListLast(local.item.getImageURL(), '.'))>
<li data-target="###arguments.cssID#" data-slide-to="#idx#" class="<cfif local.idx eq 0>active</cfif>"></li>
<cfset local.idx++>
</cfif>
</cfloop>
</ol>
</cfif>
<!--- Wrapper for slides --->
<div class="carousel-inner" role="listbox">
<cfset local.iterator.reset()>
<cfset local.idx = 0>
<cfloop condition="local.iterator.hasNext()">
<cfset local.item=iterator.next()>
<cfif ListFindNoCase('jpg,jpeg,gif,png', ListLast(local.item.getImageURL(), '.'))>
<div class="item<cfif local.idx eq 0> active</cfif>">
<img src="#local.item.getImageURL(argumentCollection=local.imageArgs)#" alt="#HTMLEditFormat(local.item.getTitle())#">
<cfif arguments.showCaption>
<div class="container">
<div class="carousel-caption">
<h2>#HTMLEditFormat(local.item.getTitle())#</h2>
#local.item.getTitle()#
<!-- <p><a class="btn btn-larg btn-primary" href="#local.item.getURL()#">Read More</a></p>-->
</div>
</div>
</cfif>
</div>
<cfset local.idx++>
</cfif>
</cfloop>
</div>
<cfif local.idx>
<!--- Controls --->
<cfif local.idx gt 1>
<a class="left carousel-control" href="###arguments.cssID#" data-slide="prev" role="button">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="###arguments.cssID#" data-slide="next" role="button">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
<!--- AutoStart --->
<cfif arguments.autoStart>
<script>jQuery(document).ready(function($){$('###arguments.cssID#').carousel({interval:#arguments.interval#});});</script>
</cfif>
</cfif>
<cfelse>
<div class="alert alert-info alert-block">
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
<h4>Oh snap!</h4>
Your feed has no items <em>with images</em>.
</div>
</cfif>
</div>
<cfelse>
<div class="alert alert-info alert-block">
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-remove"></i></button>
<h4>Heads up!</h4>
Your feed has no items.
</div>
</cfif>
<!--- // END: Bootstrap Carousel --->
</cfoutput></cfsavecontent>
How can I access the current context to output that attribute?
Here are the docs on how to display them.
http://docs.getmura.com/v6/back-end/class-extension-manager/displaying-extended-attributes/
It looks like you looping through a collection of content so I believe this would work.
#local.item.get("imageLink")#
Assuming you are working within the cfloop and after the line
<cfset local.item=iterator.next()>
You can get your custom imageLink value using
#local.item.getImageLink()#
or
#local.item.getValue('imageLink')#
Hey guys i am stuck at a point .I have a situation where i need to upload the scaled image in different folder for example :- 1(small).jpg on small folder , 1(medium).jpg on medium folder and 1.jpg on uploads folder. Right now the code below is uploading all 3 images on different folders but the files are blob files.How to get the scaled image . (edited the code)
<cfset destinationDirectory = expandpath('/file_uploader/uploads')>
<cfset counter = 1>
<cfset uniqueFileName = "">
<cfset destinationFilePath = "">
<cfset smallfile = "">
<cfset mediumfile ="">
<cfset mainfile= ''>
<cfscript>
variables.validMimeTypes = {'image/jpeg': {extension: 'jpg'}
,'image/png': {extension: 'png'}
,'image/png': {extension: 'gif'}
}; </cfscript>
<cftry>
<cfset cnt= 1>
<cfset file_name = #qqfilename#>
<cfset file_size = #qqtotalfilesize#>
<!--- If a file with the same name already exists at the destination --->
<cfif fileExists(destinationDirectory & "/" & file_name)>
<!--- Loop up to 100 times to try create a unique file_name --->
<cfset destinationFilePath = destinationDirectory & "/" & counter & "_" & file_name>
<!--- Loop up to 100 times to try create a unique filename --->
<cfloop condition="counter LT 100">
<cfset destinationFilePath = destinationDirectory & "/" & counter & "_" & file_name>
<cfif fileExists(destinationFilePath)>
<cfset counter++>
<cfelse>
<cfset uniqueFileName = "IMG" & counter & "_" & file_name>
<cfbreak/>
</cfif>
</cfloop>
<!--- Filename does not already exist at the destination --->
<cfelse>
<cfset uniqueFileName = "IMG" & "_" & file_name>
<cfset destinationFilePath = destinationDirectory & "/" & file_name>
</cfif>
<cfif len(trim(uniqueFileName))>
<cfset session.cntr ++>
<cfif find("(small)",file_name) neq 0>
<cfset smallfile = file_name>
<cffile
action="upload"
destination="#UploadPath2#"
accept="#StructKeyList(variables.validMimeTypes)#"
nameconflict="#smallfile#"
>
<cfelseif find("(medium)",file_name) neq 0>
<cfset mediumfile = file_name>
<cffile
action="upload"
filefield="qqfile"
destination="#UploadPath1#"
accept="#StructKeyList(variables.validMimeTypes)#"
nameconflict="#uniqueFileName#"
>
<cfelse>
<cfset mainfile= file_name>
<cffile
action="upload"
filefield="qqfile"
destination="#destinationFilePath#"
accept="#StructKeyList(variables.validMimeTypes)#"
nameconflict="#uniqueFileName#"
>
</cfif>
<CFSET local.response['success'] = true >
<CFSET local.response['type'] = 'xhr' >
<CFSET local.response['obj'] = session.cntr >
<cfelse>
<CFSET local.response['error'] = 'Unable to move the file and create a unique file_name at the destination'>
</cfif>
<cfoutput>
#serializeJSON(local.response,true)#
</cfoutput>
<cfabort/>
<cfcatch type="any">
<cfoutput> #serializeJSON(session.cntr,true)# </cfoutput>
<cfabort/>
</cfcatch> </cftry>
below is the UI page
<!DOCTYPE html> <html> <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- jQuery
====================================================================== -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- Fine Uploader Gallery CSS file
====================================================================== -->
<link href="../file_uploader/includes/fine-uploader-gallery.css" rel="stylesheet">
<!-- Fine Uploader JS file
====================================================================== -->
<script src="../file_uploader/includes/all.fine-uploader.js"></script>
<script src="../file_uploader/includes/all.fine-uploader.min.js"></script>
<script src="../file_uploader/includes/jquery.fine-uploader.js"></script>
<script src="../file_uploader/includes/jquery.fine-uploader.min.js"></script>
<!-- Fine Uploader Gallery template
====================================================================== -->
<script type="text/template" id="qq-template-gallery">
<div class="qq-uploader-selector qq-uploader qq-gallery" qq-drop-area-text="Drop files here">
<div class="qq-total-progress-bar-container-selector qq-total-progress-bar-container">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-total-progress-bar-selector qq-progress-bar qq-total-progress-bar"></div>
</div>
<div class="qq-upload-drop-area-selector qq-upload-drop-area" qq-hide-dropzone>
<span class="qq-upload-drop-area-text-selector"></span>
</div>
<div class="qq-upload-button-selector qq-upload-button">
<div>Upload a file </div>
</div>
<span class="qq-drop-processing-selector qq-drop-processing">
<span>Processing dropped files...</span>
<span class="qq-drop-processing-spinner-selector qq-drop-processing-spinner"></span>
</span>
<ul class="qq-upload-list-selector qq-upload-list" role="region" aria-live="polite" aria-relevant="additions removals">
<li>
<span role="status" class="qq-upload-status-text-selector qq-upload-status-text"></span>
<div class="qq-progress-bar-container-selector qq-progress-bar-container">
<div role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" class="qq-progress-bar-selector qq-progress-bar"></div>
</div>
<span class="qq-upload-spinner-selector qq-upload-spinner"></span>
<div class="qq-thumbnail-wrapper">
<img class="qq-thumbnail-selector" qq-max-size="120" qq-server-scale>
</div>
<button type="button" class="qq-upload-cancel-selector qq-upload-cancel">X</button>
<button type="button" class="qq-upload-retry-selector qq-upload-retry">
<span class="qq-btn qq-retry-icon" aria-label="Retry"></span>
Retry
</button>
<div class="qq-file-info">
<div class="qq-file-name">
<span class="qq-upload-file-selector qq-upload-file"></span>
<span class="qq-edit-filename-icon-selector qq-edit-filename-icon" aria-label="Edit filename"></span>
</div>
<input class="qq-edit-filename-selector qq-edit-filename" tabindex="0" type="text">
<span class="qq-upload-size-selector qq-upload-size"></span>
<button type="button" class="qq-btn qq-upload-delete-selector qq-upload-delete">
<span class="qq-btn qq-delete-icon" aria-label="Delete"></span>
</button>
<button type="button" class="qq-btn qq-upload-pause-selector qq-upload-pause">
<span class="qq-btn qq-pause-icon" aria-label="Pause"></span>
</button>
<button type="button" class="qq-btn qq-upload-continue-selector qq-upload-continue">
<span class="qq-btn qq-continue-icon" aria-label="Continue"></span>
</button>
</div>
</li>
</ul>
<dialog class="qq-alert-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button type="button" class="qq-cancel-button-selector">Close</button>
</div>
</dialog>
<dialog class="qq-confirm-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<div class="qq-dialog-buttons">
<button type="button" class="qq-cancel-button-selector">No</button>
<button type="button" class="qq-ok-button-selector">Yes</button>
</div>
</dialog>
<dialog class="qq-prompt-dialog-selector">
<div class="qq-dialog-message-selector"></div>
<input type="text">
<div class="qq-dialog-buttons">
<button type="button" class="qq-cancel-button-selector">Cancel</button>
<button type="button" class="qq-ok-button-selector">Ok</button>
</div>
</dialog>
</div>
</script>
<title>Fine Uploader Gallery View Demo</title> </head> <body>
<!-- Fine Uploader DOM Element
====================================================================== -->
<div id="fine-uploader-gallery"></div>
<!-- Your code to create an instance of Fine Uploader and bind to the DOM/template
====================================================================== -->
<script> var posturl = "../file_uploader/upload_file.cfm"; var t= 0;
var galleryUploader = new qq.FineUploader({
element: document.getElementById("fine-uploader-gallery"),
//debug: true,
autoUpload: false,
template: 'qq-template-gallery',
request:
{
// endpoint: '../file_uploader/upload_file.cfm?id=<cfoutput>#session.cntr#</cfoutput>'
endpoint: posturl
},
thumbnails:
{
placeholders:
{
waitingPath: '../file_uploader/includes/placeholders/waiting-generic.png',
notAvailablePath: '../file_uploader/includes/placeholders/not_available-generic.png'
}
},
validation:
{
allowedExtensions: ['jpeg', 'jpg', 'gif', 'png']
},
callbacks: {
onComplete: function(id, name, responseJSON , xhrOrXdr)
{
if (responseJSON.success)
{
t++;
alert("success"+t);
uploadSuccess: {
endpoint: "../file_uploader/upload_file.cfm?id=1"
}
}
},
onError: function(id, name, errorReason, xhrOrXdr)
{
alert(qq.format("Error on file number {} - {}. Reason: {}", id, name, errorReason));
}
},
scaling:
{
//hideScaled: true,
sizes:
[
{name: "small", maxSize: 100},
{name: "medium", maxSize: 300}
]
}
});
</script> </body> </html>
There are at least two ways to determine the scaled size of an image. One way would be to look for the appropriate prefix in the image's file name. For example, if you've instructed Fine Uploader to include the phrase "small", then you should look for the string "(small)" in the file name server-side. The same goes for any other size prefix you have specified in your scaling options.
Another option would be to look at the actual size of the files in a scaling group. Each scaled file in a group will contain a qqparentuuid request parameter pointing to the UUID of the original image/file. Once you have all of these files, you can examine their sizes to determine which one is small, medium, large, etc.
I highly suggest using the first option.
I have a cfquery that is using some of FORM fields in the WHERE clause. My first problem is that every time I access my webpage the cfquery code appears on the top of the page. Where should I put the query within the .cfm form and access some of the fields within the form? My second problem is I'm not sure that the WHERE clause is recognizing the values for the fields. Can you help me please?
Here is the way my code is set up:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
function addRow() {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
var iteration = lastRow - 3;
var row = tbl.insertRow(lastRow);
........... etcetra.......
}
</script>
</head>
<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>
<cfparam name="awardTotals" default="0" />
<cfparam name="search_award.GrandTotal" default="0" />
<cfif isDefined("form.Finalize")>
<cfquery name="search_award" datasource="Test">
SELECT g.Code1 + g.Code2 + g.Code3 + g.Code4 AS GrandTotal
FROM Codes g
WHERE g.CodeNumber = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.CodeNum#">
AND g.TestYear = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.TestYear#">
AND g.SelType = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SelType#">
AND g.Jurisdiction = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.SelJuris#">
</cfquery>
<cfif not search_award.GrandTotal is FundingTotals>
<script type="text/javascript">
alert('The totals do not match.');
return false;
</script>
<cfelse>
<script type="text/javascript">
alert('The totals match.');
return true;
</script>
</cfif>
</cfif>
<p class=MsoNormal align=center style='text-align:center'><
<cfoutput>
<form name="thisform" action="FormData.cfm" method="post">
<p class=MsoNormal align=left style='text-align:left'>
<input type="hidden" id="totalFields" name="totalFields" value="0">
<input type="text" id="awardTotals" name="#search_award.GrantTotal#" value="0">
<table width="1177" border="1" id="tblSample">
<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes'>
<th height="10"bgcolor="##cccccc" colspan="10"><h3>Jurisdiction:
<select name="SelJuris" id="SelJuris">
<option value = "0">---Jurisdictions---</option>
<option value = "1">Allegany County</option>
<option value = "2">Anne Arundel County</option>
<option value = "3">Baltimore County</option>
<option value = "4">Calvert County</option>
<option value = "5">Caroline County</option>
</select>
<input name="CodeNum" id="CodeNum" type="text" size="20">
<input name="TestYear" id="TestYear" type="text" size="20">
<input name="SelType" id="SelType" type="text" size="20">
</th>
</tr>
</table>
<input type="Submit" name="Submit Form" value="Submit Form" onClick="">
<input type="Button" name="Finalize" value="Finalize" onClick="">
</form>
</body>
</cfoutput>
</html>
(Update from comments)
Right now I'm getting a message that Element CODENUM is undefined in FORM
You want this sort of logic. If the form has been submitted, do something with it. In your case, it would be like this:
<cfif structkeyexists(form, "codenum")>
query, process, display, etc
<cfif>
rest of page
Also, you want to use query parameters for a variety of reasons. So this:
g.CodeNumber = '#form.CodeNum#'
becomes this:
g.CodeNumber = <cfqueryparam cfsqltype="cf_sql_varchar" value="#form.CodeNum#">
unless it's a number in which case you change the datatype.
You need add a condition around your cfquery. Also update the name of your submit button without spaces
<input type="Submit" name="SubmitForm" value="Submit Form" onClick="">
<cfif isDefined("form.SubmitForm")>
<cfquery name="search_award" datasource="TrenaTest">
SELECT g.Code1 + g.Code2 + g.Code3 + g.Code4 AS GrandTotal
FROM Codes g
WHERE g.CodeNumber = '#form.CodeNum#'
AND g.TestYear = '#form.TestYear#'
AND g.SelType = '#form.SelType#'
AND g.JurisdictionID = '#form.SelJuris#'
</cfquery>
</cfif>
Please note that in all the examples, a standard html form tag is being used, but the condition for the query is defined in the Coldfusion form scope. I believe you would need to convert the <form> to <cfform> and <input> to <cfinput> like:
...........
<cfinput type="Submit" name="SubmitForm" value="Submit Form" onClick="">
</cfform>
<cfif isdefined('form.submit')>
.............