Guest_imported
New member
- Jan 1, 1970
- 0
I am trying to create a custom tag that accepts two numbers as parameters and returns the sum or error messages if invalid entries. Here is my custom tag. Please advise if this is correct what do I put in my calling template?
[tt]
<CFSET hom2 = Attributes.hom2>
<CFSET NUM1 = val(Attributes.NUM1)>
<CFSET NUM2 = val(Attributes.NUM2)>
<CFSET RESULT = NUM1 + NUM2>
<CFIF #num1# is "">
<CFSET #Caller.hom_Message# = "Nothing entry for First Number!">
<CFELSEIF #num2# is "">
<CFSET #Caller.hom_Message# = "Nothing entry for Second Number!">
<CFELSE>
<CFSET #Caller.hom_Message# = "It works">
<CFSET Caller.Result = RESULT>
</CFIF>
[/tt]
My attempt at a calling template:
[tt]
<cfparam name="Form.Num1" default="0">
<cfparam name="Form.Num2" default="0">
<CFIF IsDefined("Form.Fieldnames"
>
<CF_custom2 hom2="#Form.Num1#,#Form.Num2#">
<CFOUTPUT>#Caller.hom_Message#<BR>
RESULT = #RESULT#
</CFOUTPUT>
</CFIF>
<FORM ACTION="custom2.cfm" METHOD = "POST">
<CFOUTPUT>
<table>
<tr>
<td valign="top" STYLE="FONT-WEIGHT:BOLD">NUMBER 1</td>
<td VALIGN="bottom"><input type="Text" name="num1" size="10" required="yes" /></td>
</tr>
<tr>
<td valign="top" STYLE="FONT-WEIGHT:BOLD">NUMBER 2</td>
<td VALIGN="bottom"><input type="Text" name="num2" size="10" required="yes" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="ENTER DATABASE" /></td>
</tr>
</table>
</cfoutput>
</form>
[/tt]
[tt]
<CFSET hom2 = Attributes.hom2>
<CFSET NUM1 = val(Attributes.NUM1)>
<CFSET NUM2 = val(Attributes.NUM2)>
<CFSET RESULT = NUM1 + NUM2>
<CFIF #num1# is "">
<CFSET #Caller.hom_Message# = "Nothing entry for First Number!">
<CFELSEIF #num2# is "">
<CFSET #Caller.hom_Message# = "Nothing entry for Second Number!">
<CFELSE>
<CFSET #Caller.hom_Message# = "It works">
<CFSET Caller.Result = RESULT>
</CFIF>
[/tt]
My attempt at a calling template:
[tt]
<cfparam name="Form.Num1" default="0">
<cfparam name="Form.Num2" default="0">
<CFIF IsDefined("Form.Fieldnames"

<CF_custom2 hom2="#Form.Num1#,#Form.Num2#">
<CFOUTPUT>#Caller.hom_Message#<BR>
RESULT = #RESULT#
</CFOUTPUT>
</CFIF>
<FORM ACTION="custom2.cfm" METHOD = "POST">
<CFOUTPUT>
<table>
<tr>
<td valign="top" STYLE="FONT-WEIGHT:BOLD">NUMBER 1</td>
<td VALIGN="bottom"><input type="Text" name="num1" size="10" required="yes" /></td>
</tr>
<tr>
<td valign="top" STYLE="FONT-WEIGHT:BOLD">NUMBER 2</td>
<td VALIGN="bottom"><input type="Text" name="num2" size="10" required="yes" /></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="ENTER DATABASE" /></td>
</tr>
</table>
</cfoutput>
</form>
[/tt]