Forum Moderators: open

Message Too Old, No Replies

calling two ids in one function

         

ctoz

7:52 am on Dec 18, 2010 (gmt 0)

10+ Year Member



This function ensures an id is visible:
function onV(id){
var v=document.getElementById(id).style;
v.visibility=="hidden"?v.visibility="visible":v.visibility="visible";}


Question is, how to call it twice, on different ids, in the one function? Worth finding a solution, because it's needed several times. Something like
function do2(idA,idB) {
setTimeout('onV(idA)',400); setTimeout('onV(idB)',800);}


I think the original function needs changing, so that the id there includes a second identifier, but not sure how to go about it:
function onV(id+'N'){
var N= ?
var v=document.getElementById(id+'N').style; //etc



Any pointers appreciated.

daveVk

10:06 am on Dec 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



leave onV unchanged

setTimeout('onV(idA)',400); setTimeout('onV(idB)',800);}

becomes

setTimeout('onV("' + idA + '")',400); setTimeout('onV("' + idB + '")',800);}

ctoz

8:02 am on Dec 22, 2010 (gmt 0)

10+ Year Member



Many thanks Dave