I want to send a email using a href="mailto.."
I have this working code below:
<cfset month = URL.Month>
<cfset year = URL.Year>
<cfquery datasource="newsletters" name="testing">
SELECT * FROM departments_names
where dates >='#datestart#' and dates < #dateend#
AND shooting_star_dept_name IS NOT NULL
ORDER BY
DATEPART(year, dates),
DATEPART(month, dates),
</cfquery>
<cfoutput query="testing" GROUP="deptartmetn_name">
<tr>
<td>
<a href="mailto:?subject=#month#/#year#%20%20Results%20for%20newsletters&
body=#total_count#%20#total/total_count#">
Send email to #deptartmetn_name#</a></td>
</tr>
</cfoutput>
Which just send a simple "12/2" (for example).
I would like to be able to send more than just simple text.
I would like when i click on a link to be able to send a table like below:
<table>
<thead>
<tr >
<th> First Name</th>
<th> Last Name</th>
<th>total</th>
</tr>
</thead>
<cfoutput query="testing">
<tbody>
<tr >
<td>#employee_name#</td>
<td>#employee_lastname#</td>
<td>#total_count#</td>
</tr>
</tbody>
</cfoutput>
</table>
I would like to see what I'm sending first to the recipient.
Would something like this be possible or is there a better way to do this?
My first post here and beginner to coding.
You could use an AJAX callback on your links and use cfmail with cfsavecontent (for the actual HTML content/body of the message) in your callback handler code.
Related
I'm trying to loop over information from a query and send that information in an email. Currently, based on my stored procedure, I'm displaying all the rows in the email.
This is what I'm using to get the above information:
<table>
<thead>
<tr>
<th scope="col" id="left">Admin Name</th>
<th scope="col" id="middle">Department Name</th>
<th scope="col" id="right">Last Logon</th>
</tr>
</thead>
<tbody>
<cfloop query="#inactiveAdmins#">
<tr>
<td class="text-left">#Admin_Name#</td>
<td class="text-left">#Dept_Name#</td>
<td class="">#(Len(Last_Logon) ? dateFormat(Last_Logon, 'mmm dd, yyyy') : 'Never Logged On')#</td>
</tr>
</cfloop>
</tbody>
</table>
This is displaying all Admin Names, All Department Names and all Last Logon.
I need to be able to loop over each department and send an email to each department individually.
To loop over each department, this is what I'm trying, but it's not returning any results. My question is:
Is the syntax correct?
<cfloop query="#ALEmail#">
<cfquery dbtype="query" name="inactiveSW">
SELECT Dept_ID
FROM inactiveSW
WHERE Dept_ID = <cfqueryparam cfsqltype="cf_sql_char" value="#ALEmail.Dept_ID#">
</cfquery>
</cfloop>
This is more of a comment than an answer, but it is long
should be
On this part
<cfquery dbtype="query" name="inactiveSW">
SELECT Dept_ID
FROM inactiveSW
WHERE Dept_ID = <cfqueryparam cfsqltype="cf_sql_char" value="#ALEmail.Dept_ID#">
</cfquery>
Because the FROM is the same as the name=, it is like to either have a syntax error, or overwrite an existing variable.
Besides, you are just selecting a variable that already exists. This doesn't get any new information. Are you trying to test for existence of dept_id?
Lastly, if you are trying to send an email based on a query, it is really straight forward
<cfmail
query="ALEmail"
from="#from#"
to="#to#"
subject="#subject#">
Content here
</cfmail>
Let me begin by saying that I'm a novice at ColdFusion and trying to learn so please bear with me.
I work in an apartment complex that caters to students from the local college. We have one, two and four bedroom apartments. Each room in an apartment is leased to an individual student. What I want to do is populate an HTML table with all the people in a room. My query is working and pulling all the relevant data but what is happening is that each person is being split out to their own HTML table instead of all the people in a room being put into the same table. Here is an example:
What I want
What is happening:
Here is my code:
<!---Begin data table--->
<cfoutput query = "qryGetAssignments">
<div class="datagrid">
<table>
<tr><td align="right"><strong>#RoomType#</strong></td></tr>
<thead>
<tr>
<th>#RoomNumber#</th>
</thead>
<tbody>
<tr><td><strong>#Bed#</strong>
| #FirstName# #LastName# :: #StudentNumber#
</td>
</tr>
</tbody>
</table>
</div>
</cfoutput>
I know why the output is coming out like it is, I just don't know how to fix it. I want there to be four residents in one table for a four bedroom apartment, two residents in a table for a two bedroom, and so on. Thanks in advance for your help.
Edit:
Sorry about the confusion. Here is a full pic of what I'm going for:
This should do what you need, assuming your query is properly ordered by roomType, for the <cfoutput group=""> to work.
<!---Begin data table--->
<cfoutput query="qryGetAssignments" group="roomType">
<div class="datagrid"><!--- If this isn't needed to style the tables, it can be moved outside the loop --->
<table>
<tr><td align="right"><strong>#qryGetAssignments.roomType#</strong></td></tr>
<thead>
<tr>
<th>#qryGetAssignments.roomNumber#</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<strong>#qryGetAssignments.bed#</strong>
<cfoutput><!--- this output here will loop over rows for that groupby --->
| #FirstName# #LastName# :: #StudentNumber#
</cfoutput>
</td>
</tr>
</tbody>
</table>
</div>
</cfoutput>
I've also scoped your query variables, at least I believe they are variables from a query.
That should work except it might need to be grouped by "roomNumber" such as N108.
I use cftable or cfloop to output a table of items in ColdFusion. But what is the right way to call the editor page on clicking one of table rows?
Here is the code:
<table class="grid">
<tr>
<th>id</th>
<th>Date</th>
<th>Description</th>
<th>Status</th>
<th>Urgency</th>
<th>Severity</th>
</tr>
<cfloop query="GetIssues">
<tr>
<td><cfoutput>#id#</cfoutput></td>
<td><cfoutput>#CreatedOn#</cfoutput></td>
<td><cfoutput>#ShortDesc#</cfoutput></td>
<td><cfoutput>#Status#</cfoutput></td>
<td><cfoutput>#Urgency#</cfoutput></td>
<td><cfoutput>#Severity#</cfoutput></td>
</tr>
</cfloop>
</table>
I could use a href to make GET request to editor page, but is it the right/safe way?
You can certainly create a link to the editor page and pass the ID, however, if your IDs are numeric, it will be easy for nefarious users to guess the ID of another item. To mitigate this issue, I tend to use UUIDs for my IDs. It is extremely difficult to guess at the ID of another element.
Also, it is better to wrap the cfloop in a cfoutput, rather than wrapping each td - and you should scope your variable names.
For example:
<cfoutput>
<cfloop query="GetIssues">
<tr>
<td>#GetIssues.id#</td>
<td>#GetIssues.CreatedOn#></td>
<td>#GetIssues.ShortDesc#</td>
<td>#GetIssues.Status#</cfoutput></td>
<td>#GetIssues.Urgency#</cfoutput></td>
<td>#GetIssues.Severity#</td>
</tr>
</cfloop>
</cfoutput>
I need help looping through my data and outputting it into multiple columns. Currently, it displays vertically right under the next set of data in the array. Please help.
<cfloop array="#UserAddresses#" index="UA">
<tr>
<td>City: </td>
<td><cfif NOT Len(#UA.city.xmlText#)>N/A<cfelse><cfoutput>#UA.city.xmlText#</cfoutput></cfif></td>
</tr>
<tr>
<td>State: </td>
<td><cfif NOT Len(#UA.state.xmlText#)>N/A<cfelse><cfoutput>#UA.state.xmlText#</cfoutput></cfif></td>
</tr>
<tr>
<td>Zip Code: </td>
<td><cfif NOT Len(#UA.zipcode.xmlText#)>N/A<cfelse><cfoutput>#UA.zipcode.xmlText#</cfoutput></cfif></td>
</tr>
</cfloop>
</cfif>
You want the City, State and Zip Code to be headers? Then this would work
<cfoutput>
<tr>
<td>City: </td>
<td>State: </td>
<td>Zip Code: </td>
</tr>
<cfloop array="#UserAddresses#" index="UA">
<tr>
<td><cfif NOT Len(UA.city.xmlText)>N/A<cfelse>#UA.city.xmlText#</cfif></td>
<td><cfif NOT Len(UA.state.xmlText)>N/A<cfelse>#UA.state.xmlText#<</cfif></td>
<td><cfif NOT Len(UA.zipcode.xmlText)>N/A<cfelse>#UA.zipcode.xmlText#</cfif></td>
</tr>
</cfloop>
</cfoutput>
It works because <tr></tr> defines a table row and <td></td> defines a cell in that row. In your case, you were doing multiple rows without cells, thus you were getting your content in a column, instead of a row. A side note is that <cfoutput></cfoutput> should be used only once per page and not around every variable.
I got a coldfusion query where the result is grouped on country names. With a click on this one, I try to open or close the list under the country. But i cannot work correctly with this siblings and this parents. The result is, if i click on a country name, the fourth one, for example, it close all childrens, and the three country name which are before too.
Can someone help me to choose the right selectors ?
Thank you in advance ,
Michel
The code:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
var toggleMinus = '<cfoutput>#variables.strWebAddress#</cfoutput>/images/bullet_toggle_minus.png';
var togglePlus = '<cfoutput>#variables.strWebAddress#</cfoutput>/images/bullet_toggle_plus.png';
var $subHead = $('table#categorylist tbody th:first-child');
$subHead.prepend('<img src="' +toggleMinus+ '" alt="collapse this section" /> ');
$('img', $subHead).addClass('clickable').click(function(){
var toggleSrc = $(this).attr('src');
if(toggleSrc == toggleMinus){
$(this).attr('src',togglePlus).parents('.country').siblings().fadeOut('fast');
}else{
$(this).attr('src',toggleMinus).parents('.country').siblings().fadeIn('fast');
}
});
});
</script>
<table width="95%" border="0" cellspacing="2" cellpadding="2" align="center id="categorylist">
<thead>
<tr>
<th class="text3" width="15%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTOR_CODENUMBER">
</th>
<th class="text3" width="15%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTOR_CODE">
</th>
<th class="text3" width="55%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTOR_NAME">
</th>
<th class="text3" width="15%">
<cfmodule template="../custom_tags/get_message.cfm" keyName="L_ACTIVE">
</th>
</tr>
</thead>
<tbody id="content">
<cfoutput query="qryCategoryUrl" group="country_name" groupcasesensitive="false">
<tr class="country">
<th style="font-weight:bold; text-align:left;" colspan="4">#country_name#</th>
</tr>
<cfoutput>
<tr>
<td valign="top" class="text3">#Replace(ACTOR_CODENUMBER, Chr(13) & Chr(10), "<br>", "ALL")# </td>
<td valign="top" class="text3">#Replace(ACTOR_CODE, Chr(13) & Chr(10), "<br>", "ALL")# </td>
<td valign="top" class="text3">#Replace(ACTOR_NAME, Chr(13) & Chr(10), "<br>", "ALL")# </td>
<td valign="top" class="text3"><cfmodule template="../custom_tags//get_message.cfm" keyName="#ACTIVE_display(qryCategoryUrl.ACTIVE)#"></td>
</tr>
</cfoutput>
</cfoutput>
</tbody>
</table>
Instead of:
.parents('.country').siblings().fadeOut('fast');
Try this:
.closest('.country').nextUntil('.country').fadeOut('fast');
And of course, apply the same change to the .fadeIn(). You might also look into .fadeToggle()docs.
Here's a (reduced) example: http://jsfiddle.net/redler/5sqJz/. While it doesn't affect the example, presumably you would be setting the initial state of those detail rows as hidden.
woah all that cfmodule usage, cfmodule can be a memory hog.
Although what I always recommend is that people try their pages in whatever browser, and use the SelectorGadget bookmarklet at http://www.selectorgadget.com/
This makes it easier to test and check the correct selector, for your app needs.