Solved

Javascript font color

Posted on 2003-11-15
8
1,825 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
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

828 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