Solved

Output HTML code on an IF statement

Posted on 2004-09-30
5
237 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
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.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

772 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

15 Experts available now in Live!

Get 1:1 Help Now