sonicred Posted November 26, 2010 Share Posted November 26, 2010 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 More sharing options...
Synook Posted November 26, 2010 Share Posted November 26, 2010 What does innerTd() do? Link to comment Share on other sites More sharing options...
sonicred Posted November 26, 2010 Author Share Posted November 26, 2010 What does innerTd() do?nothing specialfunction innerTd(parm,outPut){document.getElementById(outPut).innerHTML =document.getElementById(parm).value;} Link to comment Share on other sites More sharing options...
justsomeguy Posted November 29, 2010 Share Posted November 29, 2010 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 More sharing options...
sonicred Posted December 1, 2010 Author Share Posted December 1, 2010 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 More sharing options...
justsomeguy Posted December 1, 2010 Share Posted December 1, 2010 I guess, but anything becomes unstable if you don't use it correctly. Javascript isn't going to break anything. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.