I have 3 functions in which 75% of their statements are the same. Can I combine them into 1 function using parameters? If so, how do I call a parameter from a link and define them in the function?
I believe the function and links that call it would look something like this:
function One(WhatDoIPutHere) {
all common statements here;
if (Link1) {
do stuff;
}
if (Link2) {
do stuff;
}
if (Link3) {
do stuff;
}
}
<a href="javascript:void(0);" onmousedown="One('Link1')">Link1</a>
<a href="javascript:void(0);" onmousedown="One('Link2')">Link2</a>
<a href="javascript:void(0);" onmousedown="One('Link3')">Link3</a>
Thanks for your help.
I believe the function and links that call it would look something like this:
function One(WhatDoIPutHere) {
all common statements here;
if (Link1) {
do stuff;
}
if (Link2) {
do stuff;
}
if (Link3) {
do stuff;
}
}
<a href="javascript:void(0);" onmousedown="One('Link1')">Link1</a>
<a href="javascript:void(0);" onmousedown="One('Link2')">Link2</a>
<a href="javascript:void(0);" onmousedown="One('Link3')">Link3</a>
Thanks for your help.
Comment