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

check for parameter passed or not 1

Status
Not open for further replies.

Frits

Programmer
Joined
May 17, 2001
Messages
1
Location
NL
What syntax should I use to check whether an optional parameter of a javascript function has been passed or not?
 
something like this will determine if a non-false parameter was passed to the function:


function changeName(newname,field,disableit)
{
disableit = disabledit || false;
field.value = newname;
if(disableit)field.disabled = true;
} jared@eae.net -
 
this might work better, but for me, its usually fine to use the other technique:

function changeName(newname,field,disableit)
{
field.value = newname;
if(typeof(disableit)!='undefined'){
field.disabled = disableit;}
} jared@eae.net -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top