I'm having problem with this code: - function check(){
-
element1 = 2;
-
element2= 110;
-
if(element1 > element2){
-
alert('Sorry, element1 should be less than element2');
-
}
-
}
what is the problem in this code ???
5 1366 gits 5,390
Recognized Expert Moderator Expert
?? where is the problem ?? ... 2 isn't greater then 110 so you don't get the alert ...
i know that 2 isn't greater than 110 but i get the alert message how can i solve this problem I'm getting mad that is my real code: - function is_numeric(mixed_var){
-
return !isNaN(mixed_var);
-
}
-
if(is_numeric(value) && is_numeric(compv)){
-
if(condi == '<' && (compv < value)){
-
forError(this.elemID,'Sorry, '+elemID+' should be less than '+compn);
-
}else if(condi == '>' && (compv > value)){
-
forError(this.elemID,'Sorry, '+elemID+' should be greater than '+compn);
-
}else if(condi == '>=' && (compv >= value)){
-
forError(this.elemID,'Sorry, '+elemID+' should be greater than or equal '+compn);
-
}else if(condi == '<=' && (compv <= value)){
-
forError(this.elemID,'Sorry, '+elemID+' should be less than or equal '+compn);
-
}
-
}else{
-
forError(this.elemID,'Sorry, numeric letters only');
-
}
gits 5,390
Recognized Expert Moderator Expert
so you just posted the wrong code ... but i think your problem is that you in fact compare strings like that: -
element1 = '2';
-
element2 = '110';
-
-
if (element1 > element2) {
-
alert('Sorry, element1 should be less than element2');
-
}
-
so you just need to parseInt() or parseFloat() the values.
kind regards
thank you for your replay gits that was my problem.
gits 5,390
Recognized Expert Moderator Expert
no problem ... you're welcome ...
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Klatt |
last post by:
I've just encountered a strange situation (at least to me) regarding
friend operators and member operators:
#include <map>
class Key
{
friend bool operator<(const Key& lhs, const Key& rhs)
{
return lhs.myInt < rhs.myInt;
|
by: jstanforth |
last post by:
This is probably a very obvious question, but I'm not clear on what
operators need to be implemented for std::map.find() to work. For
example, I have a class MyString that wraps std::string, and which also
implements ==, <, <=, >, >=, etc. (Those operators are tested and
working correctly.)
If I assign map = "world", it saves the...
|
by: Steven D'Aprano |
last post by:
Playing around with comparisons of functions (don't ask), I discovered an
interesting bit of unintuitive behaviour:
>>> (lambda y: y) < (lambda y: y)
False
Do the comparison again and things become even more bizarre:
>>> (lambda y: y) < (lambda y: y)
True
|
by: PengYu.UT |
last post by:
I'm wonder whether
1. stl directly defined the 6 comparison operators(== != < > <= >=)
directly for iterator and const_iterator
2. or it only define == and < and using std::rel_ops to get the other 4
operators.
I made the following example for case 1. But I can not make it work.
Could you please help me to make it work.
Thanks,
|
by: Thats Me |
last post by:
TMALSS: Task With maintenance of Access Database I did not develop,
don't ask about non-commented code problems or where data dictionary
is (LOL).
Have table with Inventory data for all Publications held,
contains binder number on shelf and is text data
in numeric/alpha form i.e.; 123, 1234, 123a, 1234c.
I want to stuff the last...
| |
by: Serve La |
last post by:
Now that implementations are becoming available, I've started to
learn more about C99.
Now I was reading about the isgreater/isgreaterequal/isless/...
macro's and I'm wondering about why they are here? What's the
difference with the normal relational operators?
|
by: spam.noam |
last post by:
Hello,
Guido has decided, in python-dev, that in Py3K the id-based order
comparisons will be dropped. This means that, for example, "{} < "
will raise a TypeError instead of the current behaviour, which is
returning a value which is, really, id({}) < id().
He also said that default equality comparison will continue to be
identity-based....
|
by: Dinsdale |
last post by:
I would like to compare a string value to a pre-determined list of
other strings. Is there a simple way to do this in one statements like
this:
if(strMystring.ToUpper() == ("STRING1"| "STRING2"| "STRINGX"))
{}
This syntax doesn't work (and in fact I'm not quite sure what this
statement really is saying) but I'd like to be able to do...
|
by: Mark Rae |
last post by:
Hi,
This isn't *specifically* an ASP.NET question, so I've also posted it in the
ADO.NET group - however, it's not too far off-topic...
Imagine a SQL Server 2005 database with a table with an int column used for
bitwise data - you know the sort of thing... 0, 1, 2, 4, 8, 16 etc
intBitwise strName
----------------------
|
by: puzzlecracker |
last post by:
Unlike C++, in Csharp you're only allowed to compare a generic type T
with null, if the method it's passed in not implementing
IComparable<Tor , IEquatable<T(still don't know why we need these
two radically similar interfaces). In other words, Csharp enforces
people to not make mistake, whereas C++ follows the philosophy "if you
make a...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |