[Javascript] Comparing Strings

Laurent Muchacho elmuchacho at gmail.com
Thu Aug 25 04:31:47 CDT 2005


Hi Timothy,

You could try to put your 2 string in lowercase and that might help.
As the formating of what you get from the div innerHTML might not be 
formated the same way as you written it in the div.
An other problem you might be facing with this is that you might have 
carriage return, tab etc in your string and this are not matching.

Try sending a little bit more details about what the div contents contains 
and what your AJAX request is returning.

Personnally I will adopt an other approach and probably using a form field 
or an attribute on the div containing an id or flag and will make my check 
on this value

Hope this help

Laurent

----- Original Message ----- 
From: "Timothy White" <weirdit at gmail.com>
To: "[JavaScript List]" <javascript at latech.edu>
Sent: Thursday, August 25, 2005 8:55 AM
Subject: [Javascript] Comparing Strings


I'm using some AJAX in an application I'm building. At the moment
until I do some more advanced work I just want to compare the AJAX
results I get with the contents of a div. And if they are different
the change the div contents so they are effectively the same.
The problem is that even when the results are the same, it still
thinks they are different.
So the following is always false when it should be true practically all the 
time

if (message_text == messages.innerHTML){

I know I must be missing something, they both are strings (according
to typeof) and I know the contents are the same cause the AJAX is
returning the same thing every time.
I've even put a test condition right after "message_text =
messages.innerHTML;" and it still says that they are not equal.

I must be missing something

This should be simple!!

Thanks

Tim
p.s. It needs to be cross browser as well, so I don't want a
Firefox/Mozilla or IE only solution
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript 




More information about the Javascript mailing list