Hello, For days I've been trying to figure out how to move the value of a JavaScript variable into a Style tag value.... In the following example, I'm trying to move the value of the JS variable "panelposition1"... into the "LEFT" value of the Style "panel". I've tried doing the whole Style area in "document.write" statements ...but it ignores the whole thing then.... Anyone out there able to help???? <script language="javascript"> var aw = window.screen.availWidth //gets the available width (Available Width) var cw = aw/2 //divides the width by 2 (Center Width) var panelposition1 = cw + 60 var righttabpos = cw + 375 var sidetabpos = cw </script> <style type="text/css"> .panel{ position: absolute; top: 150; left: "javacript variable here"; width: 315; z-index: 2; height: 280; visibility: hidden; font: 8pt Verdana,sans-serif; color: b15523; border-style: solid; border-width: 1px; padding: 0; overflow: auto; } </style> thanks! john
It's strage that the outputed CSS code is ignored ... Anyway, why don't you try a different approach like this one: var panelposition1 = cw + 60 + whatever + is + needed; document.getElementById("my_panel").style.left = panelposition1 + "px"; Code (markup): It's safe an cross-browser too