Forums Register Login

overwriting

+Pie Number of slices to send: Send
if I have a FormSubmit(this) java script function, could I have another one called FormSubmit but taking 3 parameters. Can jave script function be overwritten?
+Pie Number of slices to send: Send
No, I am not aware that JavaScript functions can be overloaded.
+Pie Number of slices to send: Send
But what you can do is to test for the existance of the arguments. This way, you could call a three-parameter function with fewer arguments and test whether the parameters were passed or not.
For example, let's say we define function xyz as:

You can call this function using any number of parameters. E.g.:

Any call you make with "missing" arguments will cause the corresponding parameters to evaluate as null.
Not as clean as overloading, but at least you can get the desired effect.
hth,
bear
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 736 times.
Similar Threads
Working with a Select group and cloneNode in JavaScript
getting forceId in h:commandLink
calling servlet through hyperlink click
Ajaxstart/Ajaxstop Global Handler Form Reference
cannot get javascript to prevent duplicated form submit
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:23:23.