473,322 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Strange result in comparison function

Hi,

I have this function that checks formfields with an onChange. But it seems
to get my comparisons wrong. I've listed the function below, and give some
sample values here, the committed value is changed from 1000 to 1500 and
then gets a popup that it is greater than the Budget??? I hope someone can
help:

Budget = 10000
committed = 1500
actual = 0
accrual = 0

function ValueChanged(obj, variation){
var ChangedValue = document.getElementById(obj);
var Budget = document.getElementById("Budget" + variation);
var Committed =document.getElementById("committed" + variation);
var Actual = document.getElementById("actual" + variation);
var Accrual = document.getElementById("accrual" + variation);
var ChangedHidden = document.getElementById("changedValues" + variation);
ChangedValue.style.backgroundColor='#ffcc00';
ChangedHidden.value = true;
alert(obj + " " + Budget.value + " " + Committed.value + " " +
Actual.value + " " + Accrual.value);
//check values entered in field
//Check Committed value
if(obj == "committed" + variation){
if(Budget.value < Committed.value){
alert("Committed value can not be greater than the Budget");
Committed.focus();
Committed.select();
return false;
}
if(Committed.value < (Actual.value + Accrual.value)){
alert("Committed value can not be less than Actual + Accrual");
Committed.focus();
Committed.select();
return false;
}
}
//Check Actual value
if(obj == "actual" + variation){
alert("actual is true");
if(Actual.value > Budget.value){
alert("Actual value can not be greater than the Budget");
Actual.focus();
Actual.select();
return false;
}
if((Actual.value + Accrual.value) > Budget.value){
alert("Actual + Accrual can not be greater than the Budget");
Actual.focus();
Actual.select();
return false;
}
}
//Check Accrual
if(obj == "accrual" + variation){
alert("accrual is true");
if(Accrual.value > Budget.value){
alert("Accrual value can not be greater than the Budget");
Accrual.focus();
Accrual.select();
return false;
}
if((Actual.value + Accrual.value) > Budget.value){
alert("Actual + Accrual can not be greater than the Budget");
Accrual.focus();
Accrual.select();
return false;
}
}

}
Jul 20 '05 #1
1 1589
rf

"Marco Alting" <ma***@hotmail.com> wrote in message
news:gl***********************@amsnews02.chello.co m...
Hi,

I have this function that checks formfields with an onChange. But it seems
to get my comparisons wrong. I've listed the function below, and give some
sample values here, the committed value is changed from 1000 to 1500 and
then gets a popup that it is greater than the Budget??? I hope someone can
help:

Budget = 10000
committed = 1500


The string "1500" *is* greater than the string "10000".

Convert them to numbers.

Cheers
Richard.
Jul 20 '05 #2

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

Similar topics

24
by: brian.bird | last post by:
Can anyone explain the behaviour of python when running this script? >>> def method(n, bits=): .... bits.append(n) .... print bits .... >>> method(1) >>> method(2)
20
by: Markus Sandheide | last post by:
Hello! Execute these lines: int x = 1; x = x > 2345678901; You will get: x == 1 with Borland C++ Builder
6
by: WindAndWaves | last post by:
Hi Gurus The page below has a strange error. It seems to be working very well, just when you enter 8 or 9 for day, month or year then you get an error. I really have no idea where that is...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
8
by: Harvey Twyman | last post by:
I have code written under the CCS 'C' Compiler to run on a PIC microcontroller. Code Extract: ------------------------------- char a,b,c; ------------------------------- c = ( a == b );...
0
by: Wescotte | last post by:
<?php global $TABLE_GL_DATA; global $connect; $PREPARED_SQL = odbc_prepare($connect, "INSERT INTO $TABLE_GL_DATA VALUES (?,?,?,?,?,?,?)"); function Generate_GL_Data() {
2
by: peter | last post by:
Hi, I have very strange situation but first description ;) I have: 1) project in VB.NET, in this f.e. 1 function: Public Function Login(ByVal UserName As String, ByVal UserPassword As...
9
by: Fijoy George | last post by:
Hi all, I am a bit perplexed by the following behaviour of the 'is' comparator False True My understanding was that every literal is a constructure of an object. Thus, the '2.' in 'x = 2.'...
10
by: kyagrd | last post by:
<code> #include <iostream> int main(void) { using namespace std; int p; int* p1 = p; int* p11 = p + 2;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.