472,991 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,991 software developers and data experts.

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 2120
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
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
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
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
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
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.