Page 1 of 1

Prevent error message with optional JavaScript Parameter?

Posted: Tue Mar 25, 2008 7:55 am
by JAB Creations
I'd like to have an optional third parameter though I don't want the error console complaining when it does not exist, how do I handle an undefined parameter in such a situation? I have trued to return, return true, return false, and null though since none of them worked I presume the extent of my know-how has run out. :mrgreen:

My JavaScript looks like this...

Code: Select all

function ajax2(name3up,name2up,name1up){if (name1up == undefined) {null;}}

Re: Prevent error message with optional JavaScript Parameter?

Posted: Tue Mar 25, 2008 10:44 am
by JAB Creations
Figured it out. :mrgreen:

Code: Select all

function ajax2(name3up,name2up,name1up) { // place at the END of the script!if (typeof name1up == "undefined") {return;}}
If 'name1up' is set and you use it it won't be "undefined" so there should be no error spawned either way. :)