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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.