MDanz Posted March 4, 2010 Share Posted March 4, 2010 i have a div called layer1, which is either visible or hidden depending on some javascript. In php how do i do... if (div layer1 is visible) {} else {} or if (div layer1 is not hidden) {} else {} this is the css code when it is hidden, i can't have it if(div layer1 is hidden) because that would mess up my code. #layer1 { display:none; position:fixed; color:#FFFFFF; width: 400px; border: 1px solid #FBB917; background-color: black; padding: 5px; } Quote Link to comment https://forums.phpfreaks.com/topic/194116-if-statement-help/ Share on other sites More sharing options...
Wolphie Posted March 4, 2010 Share Posted March 4, 2010 You can only check to see if it's hidden in JavaScript. It isn't possible with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021348 Share on other sites More sharing options...
MDanz Posted March 4, 2010 Author Share Posted March 4, 2010 thx can you help me with this.. how do i use php variable in a css stylesheet? i have the variable $w, i want to use that in a css stylesheet. Quote Link to comment https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021350 Share on other sites More sharing options...
vineld Posted March 4, 2010 Share Posted March 4, 2010 What exactly is it that you want to do? Set the class in the html code instead would be my suggestion and then toggle it using javascript if that is what you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021352 Share on other sites More sharing options...
lAZLf Posted March 4, 2010 Share Posted March 4, 2010 thanks can you help me with this.. how do i use php variable in a css stylesheet? i have the variable $w, i want to use that in a css stylesheet. You can't. Php can only be used in PHP files. What you could do is not make a separate style sheet, but <style> tags in a php file and then it could be changed by a variable. But I don't know why you're even looking at PHP. What you need is to manipulate styles of objects. That's what JavaScript does best and it's very simple to do so. Quote Link to comment https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021354 Share on other sites More sharing options...
vineld Posted March 4, 2010 Share Posted March 4, 2010 That's not entirely true. You CAN use PHP in CSS as you generate it (meaning you don't have a static .css file) but it does not sound like that is what you want to do in this case. I suppose all you want to do is toggle the display depending on what the user does? Then you should simply use javascript. Quote Link to comment https://forums.phpfreaks.com/topic/194116-if-statement-help/#findComment-1021359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.