Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2006, 06:14 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default javascript boolean object

Code:
var bOneway = Boolean(document.form.oneWay.value); // contains 'False'
var bReturn = Boolean(document.forms["form"].elements["return"].value); // contains 'True'
var bOpenjaw = Boolean(document.form.openJaw.value); // contains 'False'
I am trying to change these form fields to Booleans in javascript. But the code above just sets them all to true??

Picco


www.crmpicco.co.uk
www.ie7.com
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old April 21st, 2006, 06:39 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hi Crmpicco!!
here is the answer to your question
http://www.javascriptkit.com/jsref/boolean.shtml

it describes when it returns to true and when to false.

Hope this will help you



Cheers :)

vinod
 
Old April 21st, 2006, 08:25 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

yeah, it seems you can change an object's value to a boolean though

www.crmpicco.co.uk
www.ie7.com
 
Old May 16th, 2006, 11:50 AM
Authorized User
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to guillermo
Default

Basically, if the value passed to the Boolean object is anything but 0, null, false, etc., it'll return true.

But I think the issue here is this:

var test1 = Boolean(false); // this returns false
var test2 = Boolean('False'); // this returns true
var test3 = Boolean('false'); // this also returns true

false isn't equal to 'false', nor is it equal to 'False'






Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Type in JavaScript YMas Intro Programming 4 May 30th, 2008 06:58 AM
javascript and the session object VictorVictor ASP.NET 2.0 Professional 3 April 1st, 2007 02:58 PM
Is Javascript object oriented language or not . Konan Java Basics 3 July 25th, 2006 07:09 PM
Using the Session Object and JavaScript rguidry Classic ASP Professional 10 December 23rd, 2004 05:23 PM
Date object javascript marclena Javascript How-To 2 September 10th, 2004 10:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.