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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i check if variable exists

Status
Not open for further replies.

tomy

MIS
Dec 4, 2001
1
US
in JavaScript
How do i check during the Script if variable is already exists?
 
Hi tomy! Use this:

alert(window.var_name);

where var_name is your variable name.

If it already exists, you'll get it's value.
If not, you'll see "undefined" in opened message box.

Andrew | starway@mail.com
 
you can use this:

if(varname)
{
//exists
}

or you can use:

if(typeOf(varname) != "undefined") adam@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top