Jump to content

Need help writing a function(probably really easy)


drewbert

Recommended Posts

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\" />

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.