Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
| Search | Today's Posts | Mark Forums Read
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 21st, 2005, 07:31 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I make this script into a css file? - Backg

How do I make this script into a css file? And make everything work just as it is in javascript?

<script type="text/javascript">
function SelectSize()
{
var dropDown=document.getElementById("size");
var SelectedSize = dropDown.options[dropDown.selectedIndex].value;
document.body.style.fontSize=SelectedSize + "px";
}
</script>
<form name="frmcontrol">
<select id=size onChange="SelectSize()" >
<option value="20">Default
<option value="12">Very Small
<option value="18">Smaller
<option value="26">Medium
<option value="36">Bigger
<option value="48">Larger
<option value="72">Very Large
</select>
<input type="button" value="Change Size of Text" name="myButton" onClick="SelectSize()" />
</form>

<script language="javascript">

function colorChange()
{
document.bgColor=document.list.colors.options[document.list.colors.selectedIndex].value;
}
</script>
<form name="list">
<select name="colors">
<option value="006633">Default
<option value="black">Black
<option value="white">White
<option value="yellow">Yellow
<option value="red">Red
<option value="blue">Blue
<option value="green">Green
</select>
<input type="button" value="Change Background color" name="myButton2" onClick="colorChange()" />
</form>

<BODY bgColor=#006633>

<script language="javascript">

function change()
{
document.fgColor=document.text.color.options[document.text.color.selectedIndex].value;
}
</script>
<form name="text">
<select name="color">
<option value="black">Default
<option value="black">Black
<option value="white">White
<option value="yellow">Yellow
<option value="red">Red
<option value="blue">Blue
<option value="green">Green
</select>
<input type="button" value="Change Text color" name="myButton3" onClick="change()" />
</form>

  #2 (permalink)  
Old July 21st, 2005, 07:37 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What do you mean by "make this script into a css file"? What are you trying to accomplish?

JavaScript and CSS are two quite different technologies, although they mix well. Your question is like "How do I change this pick up truck into a shopping cart".... ;)

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old July 21st, 2005, 08:08 AM
Authorized User
 
Join Date: Jul 2005
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Forget my first question, I just want to be able to link the javascript on to every page, how do I do that?

and it's in "asp format now" I can't cut and paste to every asp page, I don't have that kind of space.

  #4 (permalink)  
Old July 21st, 2005, 08:13 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Normally, you can link a JavaScript file like this:

<script type="text/javascript" src="/YourScript.js"></script>

However, this file also includes HTML so you'll need to add it to the <body> of the page. If you're using ASP, your best bet is to use a server side include.

Move your code to a new .asp file and then include it where you need it like this:



where YourInclude.asp is your file with the code and Includes is a sub folder in your site.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make the tilde work on script element hpox ASP.NET 2.0 Basics 10 February 14th, 2011 03:00 PM
How do I make a Help File? chobo2 C# 2005 1 November 13th, 2007 05:36 AM
The css file in my website gets disabled Mags VS.NET 2002/2003 3 March 27th, 2007 06:46 PM
What is CSS File in .NET ? anujrathi SQL Server 2000 1 May 7th, 2006 10:56 AM
how do i make a script run in background LIMONADA VBScript 6 April 25th, 2006 11:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.