I would like to make my script more efficient and while looking at my script which is fairly large I realize that nT.dS[v]
is repeated quite often.
I've tried do redefine it in a couple of ways, but none have worked, so I was wondering if any of you would know a way.
I need the shortening to be global. As I'm demonstrating, value is already shortened (and works well), but maybe it can be combined in another shortening to include the form id nT
, and the input id dS
, as this is the center of attention in the program.
<script id="jsGlobals">
var v = 'value'; // [v] - Global variable in HTML
...
...
...
</script>
<script id="jsCompute">
function compute(nT) {
var sTr = nT.dS[v]; // nT is formID and dS is inputID. [v] replaces .value
var q = sTr.toUpperCase();
if(q == "1") nT.dS[v] = dS116[v] //dS116 in input
if(q == "2") nT.dS[v] = dS117[v] //ds117 is input
else nT.dS[v] = eval(nT.dS[v]) ;
}
some other functions
some other functions
</script>