CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 If else statement not working.

Print topic Send  topic

Author Message
saseow

Posts: 744
Posted: 09/23/2008, 5:53 AM

In a grid with two fields and one label. I want to conditionally set the label value depending on the fields:
Form: category_weights_lu_stat
Field1: list_value
Field2: weight
Label: app_weight

The list_value is either 'Y' or 'N'. If it is 'Y' then the label gets the value of the field 'weight'. If it is no then the label gets the value of 0.

In the Before Show Row event I have custom code:
global$category_weights_lu_stat;

if($category_weights_lu_stat->list_value->GetValue == "Y") {
$category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue());
}
else
{$category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue() - $category_weights_lu_stat->weight->GetValue());
}

The label always takes the $category_weights_lu_stat->weight value and does not seem to do the else section.

Something is wrong with mu else coding. Any help would be greatly appreciated!
Thanks!

View profile  Send private message
Jack_Walter

Posts: 39
Posted: 09/23/2008, 7:04 AM

Hi,

I'm no programmer but your line

($category_weights_lu_stat->list_value->GetValue == "Y")

looks to me that you are _assigning_ "Y" to the list_value control and by default this condition will always be true...

Regards,
Jack
View profile  Send private message
saseow

Posts: 744
Posted: 09/23/2008, 7:30 AM

Thanks Jack,
I would have thought that the SetValue would assign the Y to the list_value, I am going to have to play with this some more I think.
Thanks for your reply.
Trevor
View profile  Send private message
mentecky

Posts: 321
Posted: 09/23/2008, 8:14 AM

Trevor,

Try this:
if($category_weights_lu_stat->list_value->GetValue() == "Y")   
{  
   $category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue());   
}  
else  
{  
   $category_weights_lu_stat->app_weight->SetValue( $category_weights_lu_stat->weight->GetValue() - $category_weights_lu_stat->weight->GetValue());  
}  

You are missing the parens on the first GetValue.

Rick
_________________
http://www.ccselite.com
View profile  Send private message
saseow

Posts: 744
Posted: 09/23/2008, 8:39 AM

Rick, despite your picture, you are a genius! Been searching for hours for the error.

Thank you so much!

Regards,

Trevor
View profile  Send private message
mentecky

Posts: 321
Posted: 09/24/2008, 10:29 AM

Trevor,

Don't you hate when that happens? Been there. Sometimes it just takes a second set of eyes. :-)

No problem. Glad I could help!

Rick
_________________
http://www.ccselite.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.