Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Output HTML code on an IF statement

Posted on 2004-09-30
5
240 Views
Last Modified: 2010-07-27
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
0
Comment
Question by:PhilAI
  • 2
  • 2
5 Comments
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12188767
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
0
 
LVL 6

Accepted Solution

by:
pkaleda earned 50 total points
ID: 12188777
OK.  This is pretty easy to do.  I am going to show you an overly easy example.  You need to save the page as an ASP page.

<%d
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
%>
0
 
LVL 10

Expert Comment

by:rockmansattic
ID: 12188850
sorry, I wrote it in php, NOT as you asked.

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

Rockman
0
 
LVL 6

Expert Comment

by:pkaleda
ID: 12188857
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
%>

0
 
LVL 6

Author Comment

by:PhilAI
ID: 12189634
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
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
XML problem with Internet Explorer 7 50
xml attribute DTD attribute differences 3 76
Problem to run file 9 126
Contact Forms for Website 6 83
When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question