Jump to content

combine params in function call


sonicred

Recommended Posts

hiat the moment i have this:innerTd('hiddenSTotaal','tdSTotaal');innerTd('hiddenBt','tdBt');innerTd('hiddenTaal','tdTaal');innerTd('hiddenLPerMonth','tdLPerMonth');'ll get more of the calling..is where a other way.. because.. i think its ugly this way....gr.

Link to comment
Share on other sites

Each function has an array called arguments that you can use to access everything that was passed to the function. It looks like your arguments are in pairs, so you can have your function loop through every pair of elements in the arguments array and get the first and second value in each pair, and run the code for that pair. e.g.:

function innerTd(){  for (var i = 0; i < arguments.length; i+= 2)  {	parm = arguments[i];	outPut = arguments[i + 1];	document.getElementById(outPut).innerHTML =document.getElementById(parm).value;  }}innerTd(  'hiddenSTotaal','tdSTotaal',  'hiddenBt','tdBt',  'hiddenTaal','tdTaal',  'hiddenLPerMonth','tdLPerMonth');

Link to comment
Share on other sites

Each function has an array called arguments that you can use to access everything that was passed to the function. It looks like your arguments are in pairs, so you can have your function loop through every pair of elements in the arguments array and get the first and second value in each pair, and run the code for that pair. e.g.:
function innerTd(){  for (var i = 0; i < arguments.length; i+= 2)  {	parm = arguments[i];	outPut = arguments[i + 1];	document.getElementById(outPut).innerHTML =document.getElementById(parm).value;  }}innerTd(  'hiddenSTotaal','tdSTotaal',  'hiddenBt','tdBt',  'hiddenTaal','tdTaal',  'hiddenLPerMonth','tdLPerMonth');

hithx.. i like the idea.. but it's not very stable, it could be i forget a value and it breaks totaly down not only that part..gr.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...