File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Checking a Boolean Value In JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Checking a Boolean Value In JavaScript" Watch "Checking a Boolean Value In JavaScript" New topic
Author

Checking a Boolean Value In JavaScript

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Using the following code it fires the load whether projectFlag equals true or false.

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well what you are doing looks to be the correct way to do it, but it is not.

new Boolean("any string") produces true for any string. That means a string that contains false will be evaluated as true

Your only real option here is to do



Eric
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1393
Is there any way to pass a boolean value from the servlet back to my JSP using AJAX(jQuery) call?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
if you eval / new Function it

That will cause more problems than just checking for the string.

Eric
 
jQuery in Action, 2nd edition
 
subject: Checking a Boolean Value In JavaScript
 
Similar Threads
How to check the correctness of input?
start up a new session with confirmation message
jQuery tabs UI issue
How to read a False Value
Alert Box/ Pop Up Problem