Solved

Output HTML code on an IF statement

Posted on 2004-09-30
5
242 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
[X]
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
  • 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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

717 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