Solved

Output HTML code on an IF statement

Posted on 2004-09-30
5
238 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
From XSL to Word - How add a page break? 5 29
error email attachment VB2010 5 33
Issue configuring a dropdown selector on a donation form. 13 68
CSS Question.. 3 78
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now