ctoz Posted August 17, 2007 Share Posted August 17, 2007 I've been trying unsuccessfully to extend a multiple popup script , from Code_Punk, to enable multiple style changes rather than just a single change. The purpose is to allow different IDs to show as cases in a switch function.The starting point, for a single style change is:function box(boxname,menustate){document.getElementById(boxname).style.color = menustate}And then, I've tried—with several variations on brackets and semicols:function box3 (boxname,menustate,menustate){(document.getElementById(boxname).style.display = menustate);(document.getElementById(boxname).style.visibility = menustate);(document.getElementById(boxname).style.color = menustate); }Do the 3 'menustate's need to be differentiated? Also thought about nestng the 'getElement's. Very slow cut'n'paster here: explanations welcome. Cheers Link to comment Share on other sites More sharing options...
Synook Posted August 17, 2007 Share Posted August 17, 2007 You are right, you have to have different variables for each property, or else how is the browser going to know which one you want? Though it may be simpler than you think... function box3 (boxname,display,visibility,color) { box = document.getElementById(boxname); box.style.display = display; box.style.visibility = visibility; box.style.color = color;} There! No need to nest getElementById... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.