Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

progress bar with textarea issue

Posted on 2012-03-16
1
Medium Priority
?
304 Views
Last Modified: 2012-03-16
i have successfully implemented the code for showing a progress bar to the textarea while typing, but it has one issue,

currently it works as whenever it reaches the end of the contents, it changes its color of progress bar...

currently all is working fine, my concern is if the remaining characters are left as less than 20, it should change another color as a warning sign to user

here is my code:

if some class needs to prepared to handle, plz guide thanks

var main = text_area_box.length * 100;
			var value= (main / max_numb_of_words);
			var count = max_numb_of_words - text_area_box.length;
			if(text_area_box.length <= max_numb_of_words)
			{
					$("#pbar").css("background","green");
				$('#count').html(count);
				$('#pbar').animate({"width": value+'%'}, 1);
			}
			else
			{
					$("#pbar").css("background","red");
				$("#textid").val(text_area_box.substr(0,max_numb_of_words));
			}

Open in new window



now here i also want to add a elseif block that if the textarea length left is low than 25, change color to darkred, so user should know that i have only few characters left

any guidance
0
Comment
[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
1 Comment
 
LVL 11

Accepted Solution

by:
SANDY_SK earned 2000 total points
ID: 37729156
change your if loop to

if(text_area_box.length <= max_numb_of_words)
{
        if(count <= 25){
	        $("#pbar").css("background","red");
        } else {
	        $("#pbar").css("background","green");
        }
	$('#count').html(count);
	$('#pbar').animate({"width": value+'%'}, 1);
}

Open in new window

0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

661 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