Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird Comparison Error Using Dynamic Value 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hey, I hope you can help - I am so stumped on this one.

I have a comparison where I extract the value of a query field dynamically but it does not work. Weird error: < marks the beginning of a ColdFusion tag.Did you mean LT or LTE? This is soooo unrelated it seems.

This Works
Code:
<cfoutput query="qry1">
[b]<cfif evaluate("qry1." & TableValueField) EQUAL "1001">[/b]
   <font color="red">sOptionValue: #evaluate("qry1." & TableValueField)#</font><br>
<cfelse>
   <font color="green">sOptionValue: #evaluate("qry1." & TableValueField)#</font><br>
</cfif>
</cfoutput>

This does not work
Code:
<cfoutput query="qry1">
[b]<cfif toString(evaluate("qry1." & TableValueField)) EQUAL toString(evaluate(CurrentFieldValue))>[/b]
   <font color="red">sOptionValue: #evaluate("qry1." & TableValueField)#</font><br>
<cfelse>
   <font color="green">sOptionValue: #evaluate("qry1." & TableValueField)#</font><br>
</cfif>
</cfoutput>

I have tried plying with toString() and evaluate() etc. - still no go.

What can you recommend?

Thanks,

Michael42
 
try

<cfif trim(evaluate("qry1." & TableValueField)) eq "1001">

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
bomboy,

Thanks for the post. I assume you meant the line with the error:

<cfif toString(evaluate("qry1." & TableValueField)) EQUAL trim(toString(evaluate(CurrentFieldValue)))>

Still no joy - same error as above.

Please, any other suggestions?

Thanks,

Michael42
 
No i ment trim the one coming out of the DB as i have used in my example. however it doesn't hurt to trim them both when doing a comparison

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Micheal,

take "qry1." & out from your evaluation part. The following should work:

<cfif toString(evaluate(TableValueField)) EQUAL toString(evaluate(CurrentFieldValue))>
<font color="red">sOptionValue: #evaluate(TableValueField)#</font><br>
<cfelse>
<font color="green">sOptionValue: #evaluate(TableValueField)#</font><br>
</cfif>
</cfoutput
 
iguessthehandlecheck,

Thanks very much for posting - that seemed to be the missing puzzle piece. :)

-Michael42
 
where is TableValueField coming from?

if it is a variable that holds a value like "1001" you shouldn't use evaluate. you only need evaluate in certian times such as creating dynamic variables. And even at that time you can come up with a differant method.

for example say you have
qry1.myfield1 = john
qry1.myfield2 = 555-1212
qry1.myfield3 = 101 jones street

<cfoutput>
<cfloop from = "1" to = "3" index = "count">
#evaluate("qry1.myfield" & count)#<br>
</cfloop>
</cfoutput>
for an output that will produce
john
555-1212
101 Jones Street

if you just have a simple variable holding a value you don't need to use evaluate.

name = john
<cfoutput>
#evaluate(name)#<br>
#name#
</cfoutput>
both produce "john" but the evaluate method takes longer to do thes same thing.


If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top