Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Javascript help! - (True and False variables)

Javascript help! - (True and False variables)
Thread Tools
Professional Poster
Join Date: Jan 2001
Location: Between Sydney and Melbourne
Status: Offline
Reply With Quote
Dec 22, 2004, 07:22 AM
 
Can anyone help with this?

I want to resize the window if the variable isvertical is true

It resizes anyway, even if it is false?

Any ideas?







var isvertical = false;









function clickoncolor (event, color)
{
document.getElementById('note').src = color;
if (window.widget)
{
widget.setPreferenceForKey(color, createkey("color"));
}
positioncheck (color);

isvertical = "false"

}

function clickoncolorvertical (event, color)
{
document.getElementById('note').src = color;
if (window.widget)
{
widget.setPreferenceForKey(color, createkey("color"));
}
positioncheck (color);


isvertical = "true"


}



function doneMouseUp(event)



if (isvertical = true);
{

window.resizeTo (100, 600);

}

}
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Dec 22, 2004, 10:30 AM
 
yeah....

= != ==

get it?
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Dec 22, 2004, 11:04 AM
 
You should put that in [ code ] tags so it's easier to read.

It should be isvertical = true; instead of "true" as the former is the boolean and the latter a string.

You can then use if (isvertical). To see if it is false, use if (!isvertical).
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Dec 22, 2004, 11:22 AM
 
Good catch, I didn't notice that.

I was referring to the fact that he is using the assignment operator rather than the equality operator in the following:

Code:
if (isvertical = true); { window.resizeTo (100, 600); }
That will ALWAYS evaluate to true....

He should have used:

Code:
if (isvertical == true) { window.resizeTo (100, 600); }
edit: removed erroneous semicolon
(Last edited by Kristoff; Dec 22, 2004 at 07:00 PM. )
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Professional Poster
Join Date: Jan 2001
Location: Between Sydney and Melbourne
Status: Offline
Reply With Quote
Dec 22, 2004, 06:16 PM
 
Thanks both of you, Im still having problems with the If statement always coming out true - the window always resizes (even if I set it to false immediately before!) Hope you can help!

Code:
var isvertical = false; function doneMouseUp(event) isvertical = false; if (isvertical == true); { window.resizeTo (100, 600); } }
     
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status: Offline
Reply With Quote
Dec 22, 2004, 06:59 PM
 
remove the semi colon from after the if statement (sorry I didn't notice that one earlier)
signatures are a waste of bandwidth
especially ones with political tripe in them.
     
Professional Poster
Join Date: Jan 2001
Location: Between Sydney and Melbourne
Status: Offline
Reply With Quote
Dec 22, 2004, 07:18 PM
 
Originally posted by Kristoff:
remove the semi colon from after the if statement (sorry I didn't notice that one earlier)
Thanks, it works now!

Merry Christmas!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:02 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2