On Jul 2, 12:04 pm, jodleren <sonn...@hot.eewrote:ECMAScript functions do not have arity (a fixed number of arguments that>I want to pass one or two parameters to a function, such as
function OpenDirSel(input, user)
{
}
The point: it does not work with 2 parameters, why?
Is there a way, that I can make the 2nd parameter optional?
they take). This means *all* arguments are optional on call. Whether they
are also implemented as being optional, depends on you/the function's
developer. For example:
function openDirSel(input, user)
{
/*
* Gauntlet to return if the argument value is a false-value;
* or you could throw an exception etc.
*/
if (!user) return null;
window.alert(input);
}
or
function openDirSel(input)
{
/*
* Gauntlet to return if the argument value is a false-value;
* no *named* second argument, so we use the `arguments' object.
*/
if (!arguments[1]) return null;
window.alert(input);
}
and then
if (!openDirSel("BOO!"))
{
// DEBUG: `undefined' converts to `false'
window.alert("openDirSel: Invalid second argument!");
}
Like inIt would not work because `dir1' did not refer to an object. ISTM you were
<input name="btn_dir1" type="button" value=" ... "
onclick="OpenDirSel(dir1.value, 'test');">
looking for `this' instead, to refer to the object handling the event.
Or your markup could be not Valid, so there was no script code to execute:
<http://validator.w3.org/>
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee