Link to home
Start Free TrialLog in
Avatar of PhilAI
PhilAIFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Output HTML code on an IF statement

An easy one for most, but I've only just started to work with some JavaScript, VBScript and ASP

I have a page where I have session variables

session("Brand")
session("BrandTitle")

I would like to use the HTML code
<center>
....
</center>

if the session("Brand") = "RAC", otherwise it should not center the items on the page

Thank you, Phil
Avatar of rockmansattic
rockmansattic

this php codes should do the trick
<html>
...
...

<?php if ($_SESSION['Brand']=="RAC"){echo "<center>";}?>
Blah
<?php if ($_SESSION['Brand']=="RAC"){echo "</center>";}?>

</html>

rockman
ASKER CERTIFIED SOLUTION
Avatar of pkaleda
pkaleda

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
sorry, I wrote it in php, NOT as you asked.

also there is an extra "d" at the beginning of pkaleda's code

Rockman
Thanks rockman.  I missed it.

<%
session("Brand")
session("BrandTitle")

if session("Brand") = "RAC" then
response.write("<center>")
end if
%>
.... Here you can just put standard html.  Since we removed it out of < %  and  % >  you do not have to response.write.
<%
if session("Brand") = "RAC" then
response.write("</center>")
end if
%>

Avatar of PhilAI

ASKER

I spotted the 'd' mistake thanks

Not a chance to test the code, but I am certain it will work as I simply couldn't remember (or find) the command I wanted