drewbert Posted August 17, 2010 Share Posted August 17, 2010 So I know next to nothing about PHP so I need some help with something thats probably incredibly easy. I just need a function(hope I'm using that right) that checks if a div with a certain class exists in the same page. then based on whether that's true or not changes the class of an image. This is how I imagine it looks except I don't know what to put in the if brackets to make it find the div and evaluate if its there or not. <img if (){ echo(class=\"visible\"); } else{ echo(class=\"hidden\"); } } src=\"icon.png\" /> Quote Link to comment Share on other sites More sharing options...
ober Posted August 17, 2010 Share Posted August 17, 2010 You would have to know the contents of the entire page before you knew if it contained a div with a certain class. Are you generating the rest of the page? I'm assuming that the div would have already been added by the time you're running the above code? If so, set a variable when that div is created and then read the variable when you get to this part of the page. The only other option would be to write the contents of the page to a variable and check the variable for the string containing the div. Quote Link to comment Share on other sites More sharing options...
drewbert Posted August 17, 2010 Author Share Posted August 17, 2010 It's an events calendar,which I didn't write and I'm trying to modify it so that if there is an event on a day it displays a small logo in the table as a link, then when you click on it, a small box pops up with the full event info. This pop up box is loaded from an external html file. So I need this bit of php to check the html file for a div with the class "event1" Now when I say I know nothing of PHP I mean it. I don't know how to "check the variable for the string containing the div" so if you could, would you write out the syntax for me. I don't mean to be rude or lazy, I just honestly have no clue where to start. And thank you for your quick reply and any future help. Quote Link to comment 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.