473,499 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Addition When Null value is present

I'm having trouble adding two values together when one of them has a
null value

// These two values come from a database
CEOBonusValue = 550000
CEONonEqIncentCompHidden == null
This should alert to true but doesn't

if (MarketCapHidden=="Large Caps" && CEOBonusValue +
CEONonEqIncentCompHidden < 2264001)
{
alert("true");
TotalScore = TotalScore + 2.5;
}

If I do this then it works fine.

CEOBonusValue == 550000
CEONonEqIncentCompHidden == 0

I'm not sure how to handle this. I need to keep the null values in my
database.

Thanks

May 25 '07 #1
2 2137
On May 25, 7:06 pm, shankwheat <evanbu...@gmail.comwrote:
I'm having trouble adding two values together when one of them has a
null value

// These two values come from a database
CEOBonusValue = 550000
CEONonEqIncentCompHidden == null

This should alert to true but doesn't

if (MarketCapHidden=="Large Caps" && CEOBonusValue +
CEONonEqIncentCompHidden < 2264001)
{
alert("true");
TotalScore = TotalScore + 2.5;
}

If I do this then it works fine.

CEOBonusValue == 550000
CEONonEqIncentCompHidden == 0

I'm not sure how to handle this. I need to keep the null values in my
database.

Thanks
Wait a minute, how does this javascript piece of code actually gets
this string "null", if the "null" value travels through server-side
code, and gets printed to javascript. What I mean is, if you get the
value from db in e.g. php, can't you just check immediately if the
value is null, and if it is - print it to javascript as 0? Why do you
print "null" to javascript, if you can't handle it well?

Another thing, I don't know if it's bad syntax just here in the thread
or you did the same in your scripts, but it seams you've been mixing
"==" and "=" operators... I see the piece of code:
CEOBonusValue = 550000
CEONonEqIncentCompHidden == null
- the second line isn't of much use, it should be ...dden = null,
not ...den == null (because in this way you don't actually assign it,
but just compare it)...

May 25 '07 #2
On May 25, 10:06 am, shankwheat <evanbu...@gmail.comwrote:
I'm having trouble adding two values together when one of them has a
null value

// These two values come from a database
CEOBonusValue = 550000
CEONonEqIncentCompHidden == null

This should alert to true but doesn't

if (MarketCapHidden=="Large Caps" && CEOBonusValue +
CEONonEqIncentCompHidden < 2264001)
The unary + operator will convert a null to numeric zero. E.g., you
could write:

if (MarketCapHidden=="Large Caps" && CEOBonusValue +
+CEONonEqIncentCompHidden < 2264001)

to cover off the problem as described (misuse of == notwithstanding).

--
../rh

May 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1737
by: tina.boroff | last post by:
I have a combo box that gathers insurance company names from my CCtable. If you add a name that isn't in the list it: 1)asks if you want to add the company 2)if so opens up the CCform (based...
35
9883
by: David Mathog | last post by:
Every so often one of my fgets() based programs encounters an input file containing embedded nulls. fgets is happy to read these but the embedded nulls subsequently cause problems elsewhere in...
10
3448
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
0
683
by: Jerry | last post by:
Below is ALL the code for all the databases... Here's the problem: I callup the aspx file in IE and the form comes up just fine. When I select a person to update, I get the subject error. ...
0
7131
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.