Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if null statement.

Status
Not open for further replies.

memememe

Programmer
Jul 3, 2002
5
0
0
US
can anyone tell me why this would execute commands within the braces..

var values ="";
if ( values != null);
{}
 
You initialized values to a blank string (i think thats why).

you could try

var values =null;
if ( values != null);
{}

or

var values;
if ( values != null);
{}
 
hmm nope that didn't do it. i am still getting this popup when values=null

<SCRIPT language='JavaScript'>
var values=null;
if ( values != null);
{
var theURL = &quot;pop_graph.php?categoryValues=<? echo $categoryValues; ?>&countValues=<?echo $countValues; ?>&colorValues=ff0000,ff9999,ff6666,ffcccc,ff3333&quot;
var winName = &quot;graph&quot;
var features = &quot;toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=350&quot;
surveyWin=window.open(theURL,winName,features);
surveyWin.focus();
}
</SCRIPT>
 
memememe,

they are different value types, there are 4 types in js:
Boolean (true/false)
null (var values = null)
number (29)
string &quot;inquotes&quot;

in your script, you are assigning your variable, values to a string: var values=&quot;&quot;;

in the if statement, this string is not a null data type, even though it has no value.

hope this helps ;)
~ jsLove ;)
 
jsLove...

thanks, but that didn't do it. i am still getting this popup when values=null

<SCRIPT language='JavaScript'>
var values=null;
if ( values != null);
{
var theURL = &quot;pop_graph.php&quot;
var winName = &quot;graph&quot;
var features = &quot;toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=500,height=350&quot;
surveyWin=window.open(theURL,winName,features);
surveyWin.focus();
}
</SCRIPT>
 
memememe,

the window.location value is not a string...
this works... maybe it can help

<SCRIPT language=&quot;JavaScript&quot;><!--
var valu =window.location;
valu=null;
if (valu != null){alert(valu);}
else alert('hehe');
// -->
</SCRIPT>

~ jsLove ;)
 
if ( values != null);<----------
I guess that semi colon should'nt be there.


Hope this helps

;-)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top