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!

check if total is correct if not then font is red

Status
Not open for further replies.

johnhig

MIS
Jun 25, 2007
54
US
Hi All,
I just want to check to see if the number that was entered in the total column is correct. If it is not then I want the variable to have a red colored font.

That way it flags the user that it is wrong and needs to be updated.

The wrote the following but the font says black and I know what I did wrong....again.

<CFSET CheckTotal="#NumberFormat(getmileage.tripstart + getmileage.tripend)#">
<CFSET Total ="#getmileage.triptotal#">
<CFSET ColorToUse="color: E10000; font-weight: bold;">
<CFSET Color="color: 000000">
<cfif CheckTotal eq Total>
<CFSET CheckTotal="#getmileage.triptotal#">
<CFSET Color="color: 000000">
<cfelse>
<CFSET CheckTotal="#getmileage.triptotal#">
<CFSET ColorToUse="color: E10000; font-weight: bold;">
</cfif>

Thanks John
 
Why are you defining ColorToUse and Color twice? Once outside the <cfif> and then again?

Show us how the page content looks that call these vars?

Are you forcing the user to calculate the total themselves and enter it in? If so, why? Why not just populate it automatically?

_____________________________
Just Imagine.
 
I love to just populate it, but I just learned how to do a cfloop to insert the values into my table and I don't know how to add a <cfset total = "#numberformat(tripstart + tripend)#"> to my loop

Here is my loop/insert
<cfloop from="1" to="#form.numba#" index="idx">
<cfset getproject = evaluate("form.projectid" & idx)>
<cfset gettask = evaluate("form.taskid" & idx)>
<cfset getvehicle = evaluate("form.vehicle" & idx)>
<cfset getassigned = evaluate("form.assigned" & idx)>
<cfset getdate = evaluate("form.tripdate" & idx)>
<cfset getcust = evaluate("form.tripcust" & idx)>
<cfset getdest = evaluate("form.tripdest" & idx)>
<cfset getstart = evaluate("form.tripstart" & idx)>
<cfset getend = evaluate("form.tripend" & idx)>
<cfset getthru = evaluate("form.tripthru" & idx)>
<cfset getstate = evaluate("form.tripstate" & idx)>
<cfset gettotal = evaluate("form.triptotal" & idx)>
<cfquery name="data" datasource="intranet">
insert into mileage (projectid,taskid,vehicle,tech,tripdate,tripcust,tripdest,tripstart,tripend,tripthru,tripstate,triptotal)
values ('#getproject#','#gettask#','#getvehicle#','#getassigned#','#getdate#','#getcust#','#getdest#','#getstart#','#getend#','#getthru#','#getstate#','#gettotal#')
</cfquery>
</cfloop>
 
ok....so I took a look at what you suggested on my query that loops. I am trying changed the following so it populates the total for the user.

<cfset gettotal = evaluate("form.triptotal" & idx)>

to

<cfset gettotal = evaluate("form.tripstart" + "form.tripend" & idx)>

Now I get the message that form.tripstart can not be converted to a number.

what am I doing wrong?
 
ok so I am getting closer...I changed the evaluate to this

<cfset gettotal = evaluate("form.tripstart" & idx) + ("form.tripend" & idx)>

and message now reads that it can not conver form.tripend1 to a number....

so it is reading form.tripstart1, so it must be a syntax somewhere.

I keep posting my progress, because everytime I do I seem to get a bit farther.

John
 
Well it worked.


<cfset gettotal = evaluate("form.tripstart" & idx) + evaluate("form.tripend" & idx)>

seemed to do the trick.

 
Just a coding tip that you may find helpful, especially as your experience grows:

change:

evaluate("form.tripstart" & idx)

to:

FORM["tripstart" & idx]

avoid evaluate() if possible (almost always possible.)

Kevin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top