Copy link to clipboard
Copied
Hi everybody - kinda new here. I was hired at a web design company last year and have recently taken to learning ColdFusion - so I'm not 100% on the syntax. I always need help with if statements, so I'm hoping you guys will be willing to spread some knowledge.
Anyway to put this in context:
What I'm working on is a Calendar that allows you to register to attend an event, such as a corporate dinner, holiday party, or some such nonsense. It also processes ticket purchases through a 3rd party such as PayPal, and would look something like this when put on a web-page.
Here's the code that creates that display.
<table class="registerTablePrices" cellspacing=5>
<cfloop query="registration_types">
<cfif registration_types.esl_price gte 0>
<tr>
<td class="formlabel" nowrap>#registration_types.estName#:</td>
<td><cfinput name="regType_#registration_types.estid#" style="width:30px" value="0"/></td>
<cfif registration_types.esl_price is 0>
<td class="formlabel"> X Free</td>
<cfelse>
<td class="formlabel" style="width:90px"> X #dollarformat(registration_types.esl_price)#</td>
</cfif>
<td class="labelInfo">Enter number of attendees for this type.</td>
</tr>
</cfif>
</cfloop>
</table>
All the code says at the moment is to display events whose price is positive, or else list them as free.
Here is what I want - I want to make it so that the May 30th Late Registration will automatically be hidden if the date is BEFORE or AFTER May 30th.
I have assigned values to the registration types that I want to restrict by date...
They are registration_types.estStartDate and registration_types.estEndDate
AND the value that designates it as Restricted, registration_types.estRestricted - which would be used like this.
<cfif registration_types.estRestricted is 1>
* Then only show it between registration_types.estStartDate and registration_types.estEndDate
And that's where I run into my problem. I can't make it work with the first code you saw:
<table class="registerTablePrices" cellspacing=5>
<cfloop query="registration_types">
<cfif registration_types.esl_price gte 0>
<tr>
<td class="formlabel" nowrap>#registration_types.estName#:</td>
<td><cfinput name="regType_#registration_types.estid#" style="width:30px" value="0"/></td>
<cfif registration_types.esl_price is 0>
<td class="formlabel"> X Free</td>
<cfelse>
<td class="formlabel" style="width:90px"> X #dollarformat(registration_types.esl_price)#</td>
</cfif>
<td class="labelInfo">Enter number of attendees for this type.</td>
</tr>
</cfif>
</cfloop>
</table>
I'm going to have at least 4 special conditions going on at once and I lose it there.
If you read all that I'm sorry, it may be hard to fully understand - I appreciate any help.
I wasn't sure what you wanted to do. Perhaps, this:
<cfif (registration_types.esl_price gte 0)
or (registration_types.estRestricted is 1 and ((current_date ge estStartDate) and (current_date le estEndDate)))>
You can also compare the dates using dateCompare().
<cfset current_date = dateFormat(now(), "mm/dd/yyyy") />
<cfloop query="registration_types">
<cfif (registration_types.esl_price gte 0)
or (registration_types.estRestricted is 1 and ((current_da
...Copy link to clipboard
Copied
I wasn't sure what you wanted to do. Perhaps, this:
<cfif (registration_types.esl_price gte 0)
or (registration_types.estRestricted is 1 and ((current_date ge estStartDate) and (current_date le estEndDate)))>
You can also compare the dates using dateCompare().
<cfset current_date = dateFormat(now(), "mm/dd/yyyy") />
<cfloop query="registration_types">
<cfif (registration_types.esl_price gte 0)
or (registration_types.estRestricted is 1 and ((current_date ge estStartDate) and (current_date le estEndDate)))>
#registration_types.estName#:
<cfinput name="regType_#registration_types.estid#" value="0"/>
<cfif registration_types.esl_price is 0>
X Free
<cfelse>
X #dollarformat(registration_types.esl_price)#
</cfif>
Enter number of attendees for this type.
</cfif>
</cfloop>
Copy link to clipboard
Copied
I got the issue solved today, thanks in part to your post.
Thank you!!