[Javascript] Passing a variable to a Function
Peter Brunone
peter at brunone.com
Thu Nov 20 14:00:33 CST 2003
>However, I would recommend you to use the onclick event instead, be sure
>to return false after you call the function, and use # as the target for
>the href attribute.
Why do you recommend doing that? It's never made sense to me to create an extra handler when there's already a default handler that suffices. I've heard several folks over the years who agree with you, but none of them have given any further explanation.
Cheers,
Peter
>From: liorean <liorean at f2o.org>
>Kevin.Gutch at mapinfo.com wrote:
>> I would like to pass a value to a function [- - -]
>> I really want to pass a dynamic value/variable to the function. How would I
>> go about doing this in the function call? When I try it just gets passed as
>> a String.
>>
>> <a href="javascript:myFunction(myVariable);">myVariable</a>
>>
>> Am I making myself clear?
>
>I believe that code is executed within the document scope instead of the
>window scope. Try href="javascript:myFunction(window.myVariable);".
>However, I would recommend you to use the onclick event instead, be sure
>to return false after you call the function, and use # as the target for
>the href attribute.
>
>--
>liorean <mailto:liorean at user.bip.net>
More information about the Javascript
mailing list