Link to home
Start Free TrialLog in
Avatar of Michael Cripps
Michael Cripps

asked on

Show hide HTML Div based on PHP variable, using javascript

Need to show or hide a DIV with Javascript based off of PHP string variable. Basically, I have a DIV with a lot of information and do not want to show it on the page, if the information supplier with the PHP script has not values. I am testing the value by setting a php variable and want to use javascript to see if there is a string in the php variable and if so, show the div. If the string is empty or blank, then hide the DIV.
Avatar of kenfcamp
kenfcamp
Flag of United States of America image

Do you know the string variable that you want to see returned?
why not using PHP directly ?
old school :
<?php
   if(!empty(thestring)) {
?>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
      <div>WE SHOW THE DIV</div>
<?php
   }
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michael Cripps
Michael Cripps

ASKER

Nice job. Worked perfectly.