jodleren wrote:
ECMAScript functions do not have arity (a fixed number of arguments that
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(inpu t, 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(in put);
}
or
function openDirSel(inpu t)
{
/*
* 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(in put);
}
and then
if (!openDirSel("B OO!"))
{
// DEBUG: `undefined' converts to `false'
window.alert("o penDirSel: Invalid second argument!");
}
It would not work because `dir1' did not refer to an object. ISTM you were
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.or g/>
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
On Jul 2, 12:04 pm, jodleren <sonn...@hot.ee wrote:
>I want to pass one or two parameters to a function, such as
>>
> function OpenDirSel(inpu t, user)
> {
> }
>>
>The point: it does not work with 2 parameters, why?
>Is there a way, that I can make the 2nd parameter optional?
>>
> function OpenDirSel(inpu t, 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(inpu t, 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(in put);
}
or
function openDirSel(inpu t)
{
/*
* 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(in put);
}
and then
if (!openDirSel("B OO!"))
{
// DEBUG: `undefined' converts to `false'
window.alert("o penDirSel: Invalid second argument!");
}
Like in
<input name="btn_dir1" type="button" value=" ... "
onclick="OpenDi rSel(dir1.value , 'test');">
<input name="btn_dir1" type="button" value=" ... "
onclick="OpenDi rSel(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.or g/>
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
Comment