473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

CSS - Replace coded values with data from a database

Hello - I tried posting this to the CSS Forum, but was told to come here instead.
I want to code a CSS file so that I can replace the values for font, size, and color with values that have been derived from a database and put in variables.
I use this approach throughout my application to let users setup various options so I don't have to modify code. (ASP )

Example: <font face='arial'> is coded as
<font face=' " & HD1 & " '> (HD1 is set by reading a "global" table with the font face in it.)

Works great in asp/html, but I have a CSS-driven menu & I want to do the same type of replacement, but I can't get the syntax right. Is this even possible?

Thanks . . . Breck Cogdill
Oct 8 '07 #1
4 1832
jhardman
3,406 Expert 2GB
Breck,

Yes, this should be perfectly doable, but realize that if your css is on a separate file, the web server will not execute any script on that file unless it has file extension .asp. Give an example of what you have tried, and we can try to help you make it work.

Jared
Oct 9 '07 #2
Breck,

Yes, this should be perfectly doable, but realize that if your css is on a separate file, the web server will not execute any script on that file unless it has file extension .asp. Give an example of what you have tried, and we can try to help you make it work.

Jared

Jared - Thank you for you reply, I'm including the CSS info below & sections of other ASP code that relates to the issue.

Quick overview:

I have sites that allow users to set various options, fonts/sizes/colors, etc.

An ASP program - Get Global.asp reads from a d/b table & gets data to be "replaced" in HTML tags.

GetGlobal.asp code:

SQL = "SELECT * FROM GLOBALTABLE "
Set GLB = Server.CreateObject("ADODB.Recordset")
GLB.Open sql,conn
dFont = glb.fields("DefaultFont")
dSize = glb.fields("DefaultFontSize")
-------------------------------------------------------------------------------
Font tags in ASP code:

<font face=' " & dFont & " ' size=' " & dSize & " '>
-------------------------------------------------------------------------------

CSS code in Menu program:

/* defines the format of menu items when the mouse is not over them */
.menuitem_normal
{font: 7pt Arial, sans serif;
color: #5A9ECE;
background-color: #FFFFFF;
line-height: 110%
}

I want to be able to let the users set the font values using values derived from the d/b just like it works in the ASP code.

I know controlling page colors, etc. from a d/b sort of defeats the purpose of CSS, but I don't want to have to modify code to change the values. (Plus, I don't know how to code CSS, or I wouldn't be here in the first place.)

I inherited most of this code, including the Menu which uses the CSS, & I've retrofitted the font tag replacements throughout the application, this is the last place I need to make database-driven & then I won't have to do a thing to change layout colors, fonts, etc. in my package.

Thanks again for helping me with this . . . .Breck Cogdill
Oct 9 '07 #3
Jared - Thank you for you reply, I'm including the CSS info below & sections of other ASP code that relates to the issue.

Quick overview:

I have sites that allow users to set various options, fonts/sizes/colors, etc.

An ASP program - Get Global.asp reads from a d/b table & gets data to be "replaced" in HTML tags.

GetGlobal.asp code:

SQL = "SELECT * FROM GLOBALTABLE "
Set GLB = Server.CreateObject("ADODB.Recordset")
GLB.Open sql,conn
dFont = glb.fields("DefaultFont")
dSize = glb.fields("DefaultFontSize")
-------------------------------------------------------------------------------
Font tags in ASP code:

<font face=' " & dFont & " ' size=' " & dSize & " '>
-------------------------------------------------------------------------------

CSS code in Menu program:

/* defines the format of menu items when the mouse is not over them */
.menuitem_normal
{font: 7pt Arial, sans serif;
color: #5A9ECE;
background-color: #FFFFFF;
line-height: 110%
}

I want to be able to let the users set the font values using values derived from the d/b just like it works in the ASP code.

I know controlling page colors, etc. from a d/b sort of defeats the purpose of CSS, but I don't want to have to modify code to change the values. (Plus, I don't know how to code CSS, or I wouldn't be here in the first place.)

I inherited most of this code, including the Menu which uses the CSS, & I've retrofitted the font tag replacements throughout the application, this is the last place I need to make database-driven & then I won't have to do a thing to change layout colors, fonts, etc. in my package.

Thanks again for helping me with this . . . .Breck Cogdill

Jared - I'm sorry, I neglected to mention that the CSS is in a separate CSS file that is referenced in each ASP program:

<link rel="stylesheet" href="simplemenu2.css" type="text/css">
Oct 9 '07 #4
jhardman
3,406 Expert 2GB
Beck,

1- change the simplemenu2.css to simplemenu2.asp (i think this will work. I've never tried it before, but I belive it should work)

2- Put your db connection code in the simplemenu2.asp

3- List the font code as:
Expand|Select|Wrap|Line Numbers
  1. {font: <%=dSize & " " & dFont%>, sans serif;
That should solve the whole problem (except the "sans serif" part. Css allows for a backup font if the font chosen isn't available on the user's computer. In this case, the css says to use the systems default sans serif font, Arial on most computers, if the chosen font isn't available. It is up to you whether this is good enough.) Let me know if it gives you any more problems.

Jared
Oct 11 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: Westcoast Sheri | last post by:
To keep track of how many fruits my visitors buy, I use a mySQL database (2 columns: "fruit" and "quantity")....so can we make these following mySQL queries work somehow? (visitor buys 5...
10
by: Brett | last post by:
If I have many hard coded values such as file paths, file names, timeouts, etc, where is the best place to define them? Meaning, in the case something needs changing for example, rather than...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
9
by: MrHelpMe | last post by:
Hello again experts, I have successfully pulled data from an LDAP server and now what I want to do is drop the data into a database table. The following is my code that will insert the data but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.