Solved

Javascript font color

Posted on 2003-11-15
8
1,836 Views
Last Modified: 2013-12-03
Hello All,

I am using a javascript function I found on the internet to display a progress bar on the screen. My problem is that right now the progress bar "text", the text that moves across the screen to simulate that something is happening is black. I would like to make it another color but can't seem to find the proper syntax for doing this?

Any help? This is the code
var _progressBar = new String("");
_progressBar.fontcolor('red');   // THIS DOES NOT WORK?
var _progressEnd = 10;
var _progressAt = 0;
var _progressWidth = 150;      // Display width of progress bar

Thanks for the help.
Mike
0
Comment
Question by:MichaelVB
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
ID: 9754214
Hi,

document.write('<div id="bar">' + _progressBar + '</div>')
document.getElementById('bar').style.color = 'red';  

Vinny
0
 
LVL 15

Expert Comment

by:JakobA
ID: 9754218
Are you sure this is Javascript ?   for one thing variable-names starting with an '_' character should not be used (they are reserved for predefined values)

I am afraid I would need to see the entire script to make sense of this. could you give a link to the place where you found it?
0
 
LVL 31

Expert Comment

by:GwynforWeb
ID: 9754371
I can not see  your code but I would image you are using a span,div,table or cell  with some id or a name for the bar.  I think you need this you want this

var _progressBarColor='red'  
var _progressEnd = 10;

if  obj is the name or id and where you have something like this for a span or div  

document.getElementById('obj').style.color = _progressBarColor
or
document.getElementByIName('obj').style.color = '_progressBarColor

 for a table cell replace 'color' with 'background'

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 31

Accepted Solution

by:
GwynforWeb earned 50 total points
ID: 9754393
typos should read

I can not see your code but I would imagine you are using a span, div, table or table cell  with some id or a name for the bar.  I think you need something like this

var _progressBarColor='red'  
var _progressEnd = 10;
etc

If  obj is the name or id  then use  for a span or div  

document.getElementById('obj').style.color = _progressBarColor
or
document.getElementByIName('obj').style.color = _progressBarColor

for a table or table  cell replace 'color' with 'background'




0
 

Author Comment

by:MichaelVB
ID: 9754406
this is where I found the code

http://javascript.internet.com/messages/progress-dialog.html

thanks,
Mike
0
 
LVL 25

Expert Comment

by:devic
ID: 9754424
hey MichaelVB ,

maybe do you want prototype?
here is example:
===================================
<script>
function runit()
{

var progressBar = new String("Any help? This is the code");
String.prototype.color = "red";
String.prototype.colored = textColor;
progressBar = progressBar.colored();

document.write(progressBar)
}

function textColor()
{
   return "<FONT color='" + this.color  + "'>" + this + "</FONT>";
}
</script>
<button onclick=runit()>runit</button>
0
 
LVL 25

Assisted Solution

by:devic
devic earned 200 total points
ID: 9754430
just change this line:
document.write("<input type=text name=\"bar\" size=\"" + _progressWidth/2 + "\"");

to this:
document.write("<input style=color:red type=text name=\"bar\" size=\"" + _progressWidth/2 + "\"");
0
 
LVL 15

Expert Comment

by:JakobA
ID: 9754433
Sorry, That script is horribly Old. written for IE4 and Netscape4. It might work in newer versions of IE, but not in newer netscape or any browser using the DOM model.

I would suggest you scrap it and replace it with code based on GwynforWebs code. evt get him to complete it. ( but no variablenames starting with '_' please :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

690 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