Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2005, 02:06 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default Format number function problem

I have a traffic light system that show product performace at basses. This was a finished page until the client wanted to weight the products and the bases. Weightings are between 0 and 1.0 - There are two select boxes on the page that allow you to filter the results EG. Only show me products where the weighting = 1.0 or = .5 etc. You may choose a baseWeighting, productWeighting or a combination of the two.

The values being passed in the select boxes are as illustrated above however there is now a need to include EG where someWeighting <=.5 Or someWeighting >=.5

I am using the FormatNumber function to ensure values are being compared like so 1.0 or .1 or .5 etc. The two IF conditions below work like a treat when there is no < or > involved in the values being compared. When either of these two conditions are asked for they are put into the variables:
1..prodFilter = selected product filter condition
2..baseFilter = selected base filter condition
They are being compared to the weighting values:
1..reviews(4) = productWeighting
2..bases(2) = baseWeighting

The page errors out when either >.5 or <.5 conditions are selected, otherwise it works trouble free. I know why I get the error: You cant run the formatNumber function against a value that has > or < within - I am having a little trouble finding a solution. Here is the start of the statement that detects a filter has been asked for:

IF (prodFilter <> "" AND prodFilter <> "all") or (baseFilter <> "" AND baseFilter <> "all") THEN
   IF (formatNumber("0" & prodFilter,1) = formatNumber("0" & reviews(4),1)) OR formatNumber("0" & baseFilter,1) = formatNumber("0" & bases(2),1) THEN....

Wind is your friend
Matt
__________________
Wind is your friend
Matt
 
Old May 7th, 2005, 09:22 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

damn, seems so simple. I am about to completely change the design plan of the page to focus on changing the SQL - this causes a problem: I want to show the assessments (traffic lights) base on the user defined conditions as explained above. The reason I still need all the records; there is an average column at the end. Regardless of what results are showing based on user selections I need to show the line average for all items.

Why wouldnt this work (runs trouble free but does not show the correct records):

IF (prodFilter <> "" AND prodFilter <> "all") or (baseFilter <> "" AND baseFilter <> "all") THEN
   IF (formatNumber("0" & prodFilter,1) = formatNumber("0" & reviews(4),1)) OR (baseFilter = "<=.5" AND bases(2) <= ".5" ) OR (baseFilter = ">=.5" AND bases(2) >= ".5" ) THEN....

FYI the two trailing OR conditions is the problem area:
OR (baseFilter = "<=.5" AND bases(2) <= ".5" )
OR (baseFilter = ">=.5" AND bases(2) >= ".5" )

The baseFilter var is equal to "<=.5" and ">=.5"
and bases(2) is equal to ".5"


Wind is your friend
Matt





Similar Threads
Thread Thread Starter Forum Replies Last Post
format-number function problem jeffbk XSLT 8 May 5th, 2007 03:20 AM
Format Number Dink Classic ASP Databases 2 January 23rd, 2007 01:40 AM
Number Format - Need Help! bridog39 Access 7 November 14th, 2005 02:50 PM
Format Number hcweb Classic ASP Basics 4 October 27th, 2004 11:23 AM
format number tgopal Javascript 2 April 30th, 2004 03:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.