 |
 |
Javascript help! - (True and False variables)
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2001
Location: Between Sydney and Melbourne
Status:
Offline
|
|
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
|
|
|
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status:
Offline
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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!
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|