Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

Display or Hide Recordset Data

Posted 02 May 2005 08:05:04
1
has voted
02 May 2005 08:05:04 Frank Warwick posted:
Hi All
I am trying to allow, via the admin section, the ability to change the background colours of a table.
The problems I am having is as follows;
- I have 4 of these sections on a dynamic template page
- not all the sections are used each time the template is called
- I want to either make the colours default to a specific colour if used or if not used, then to display a set colour

I see 2 ways for this to happen;
1 - if statements for the colours
- or -
2 - SQL statement to disallow the table to be shown unless content is posted in the database

I am new to SQL and 'if' statements.
I am using dreamweaver MX 2004 with access 2000.

This is the code want to be able to hide, I have 4 of these section on a page.
<pre id=code><font face=courier size=2 id=code>
------------------------------------------------------------------------------------------------
&lt;table width="150" border="0" cellpadding="1" cellspacing="0" bgcolor="#&lt;%=(rs_pages.Fields.Item("S_SideHeading4_ColourBG".Value)%&gt;"&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;table width="150" border="0" cellspacing="0" cellpadding="4"&gt;
&lt;tr&gt;
&lt;td align="center" bgcolor="#&lt;%=(rs_pages.Fields.Item("S_SideHeading4_ColourBG".Value)%&gt;"&gt;&lt;strong&gt;&lt;%=(rs_pages.Fields.Item("S_SideHeading4".Value)%&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td bgcolor="#&lt;%=(rs_pages.Fields.Item("S_SideContent4_ColourBG".Value)%&gt;"&gt;
&lt;%Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject"
objFile = Request.ServerVariables("SCRIPT_NAME"
ImagePath = Server.MapPath("../site_images\"
ImagePath = ImagePath & "\" & (rs_pages.Fields.Item("S_SideImage4".Value)
If objFileSystem.FileExists(ImagePath) then%&gt;
&lt;img src="../site_images/&lt;%=(rs_pages.Fields.Item("S_SideImage4".Value)%&gt;" border="0" align="right" /&gt;&lt;%=(rs_pages.Fields.Item("S_SideHeading4".Value)%&gt;
&lt;%End If%&gt;

&lt;%= CI_Preserve((rs_pages.Fields.Item("S_SideContent4".Value)) %&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
------------------------------------------------------------------------------------------------
</font id=code></pre id=code>

Your help with this would be much apprecated

Replies

Replied 02 May 2005 20:06:04
02 May 2005 20:06:04 Chris Charlton replied:
If you plan on having more than 3 options, then I suggest looking into a <i>switch case</i> statement in ASP. Then you can even have a <i>default</i> asyou will see.

I'd use the <i>switch case</i> statment to set a CSS class style variable, then just use that for the style/class. <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>

~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 03 May 2005 02:07:24
03 May 2005 02:07:24 Frank Warwick replied:
Hi Chris and thanks
now I need to ask you about 'switch case statements to set a CSS class style variable'
this is new to me and I could use a bit of direction with this, call me stupid, call me thick, but I don’t pick these things up quickly (I'm a slow study) so your help is greatly appreciated.
thank you
Replied 03 May 2005 16:38:30
03 May 2005 16:38:30 Chris Charlton replied:
Here's a documentation, for JScript, so it should work generally the same for ASP.
msdn.microsoft.com/library/default.asp?url=/library/en-us/jscript7/html/jsstmswitch.asp

And for the basics of CSS, check DW's help tutorials, and here at DMXzone, there's a bunch of CSS articles. If you want to know about <i>class selectors</i> directly, then check out:www.w3schools.com/css/css_syntax.asp

~ ~ ~ ~ ~ ~ ~
Chris Charlton <i>- DMXzone Manager</i>
<font size=1>[ Studio MX/MX2004 | PHP/ASP | SQL | XHTML/CSS | XML | Actionscript | Web Accessibility | MX Extensibility ]</font id=size1>
Replied 20 May 2005 16:20:32
20 May 2005 16:20:32 Frank Warwick replied:
Hi Chris
I guess what my real problem is that when I wrap the above code with an if statement to hide if no content is available it does not work, if I wrap it with a statement to say dont show if there is content then it works even on the pages that dont have any content pulled from the database.

could this have anything to do with it?
this is in the middle of the table I have above

&lt;%Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject"
objFile = Request.ServerVariables("SCRIPT_NAME"
ImagePath = Server.MapPath("../site_images\"
ImagePath = ImagePath & "\" & (rs_pages.Fields.Item("S_SideImage4".Value)
<font color=red>If objFileSystem.FileExists(ImagePath) then%&gt;
&lt;img src="../images/&lt;%=(rs_pages.Fields.Item("S_SideImage4".Value)%&gt;" border="0" align="right" /&gt;&lt;%=(rs_pages.Fields.Item("S_SideHeading4".Value)%&gt;
&lt;%End If%&gt;</font id=red>

the red 'if' statement works but I cant hide the table that wraps around it
or could I use the same style as above to hide the table????

any ideas?

Reply to this topic