Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End If a div has no content – add class for display:none ?

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #35541
    standuncan
    Member

    I’m trying to come up with a solution, where if a div is empty, I would like to add a class so that I can display:none;. I tried searching without any luck.

    I don’t know how to write this expression though? Any help would be appreciated :)




    echo $errors;
    echo $errors;
    echo $errors;
    echo $errors;
    ?>


    #92216
    TheDoc
    Member

    I don’t really know what you’re doing… but what if it was more like this:

    
    // do nothing
    } else { ?>
    #92219
    standuncan
    Member

    I have a div that contains all my errors on a form. I have it styled and positioned where needed, but when there are no errors, I would like the div to not be visible.

    I’m going to see if I can work with the idea above, thanks.

    #92233
    standuncan
    Member

    Well that’s not going over too well lol. I tried writing that function ( I always get mixed up about the names of php [statements/expressions/functions]) outside the div, inside the class=”” itself and lots of different ways, I could never get it to work. I think I was doing it wrong, but not sure?

    #92237
    TheDoc
    Member

    I’m not the strongest with PHP, so my solution might not be EXACTLY what you need to write.

    #92238
    standuncan
    Member

    Thanks for trying @TheDoc.

    #92239
    TheDoc
    Member

    Even with my limited knowledge, there has to be something we can do! What code did you try?

    #92242
    standuncan
    Member

    Sweet, I asked a buddy and he helped out. I was thinking of it the same way and trying like you said, if empty do not display vice if not empty display.



    if(!empty($errors)){
    echo '
    ';
    echo $errors;
    echo '
    ';
    }
    ?>

    #92252
    TheDoc
    Member

    I think that’s what he finished with there.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Back End’ is closed to new topics and replies.