{"id":1624,"date":"2008-08-12T01:26:35","date_gmt":"2008-08-12T05:26:35","guid":{"rendered":"http:\/\/teamtutorials.com\/?p=1624"},"modified":"2008-10-26T14:45:17","modified_gmt":"2008-10-26T18:45:17","slug":"javascript-progress-bar","status":"publish","type":"post","link":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar","title":{"rendered":"JavaScript Progress Bar"},"content":{"rendered":"

This tutorial will walk you through Configuring a javascript based progress bar that can triggered by several things. You could have it triggered by how many results are pulled back from a database, or you could have it triggered by the length of a textbox (passwords), or even trigger it by checkboxes that are checked. For the purpose of this tutorial we are going to trigger it with checkboxes. Let\u2019s get started. <\/p>\n

Goto the bram.us website<\/a> to download the files that will make the progress bar work. <\/p>\n\"javascript_progress_bar_01\"<\/a>\n

First you will be at the site to download the software. Click on the link to download the latest version. Save the file to your computer somewhere where you can access it. It will be in ZIP format so you will need to extract the files within it.<\/p>\n\"javascript_progress_bar_02\"<\/a>\n

You should have a folder that contains these folders and the one file. That html file is the demo that is given with the progress bar. You can delete it or you can keep it for you to look at later if you ever want to go back and look at how it works. We, however, will be making a new file from scratch to call these scripts. Let\u2019s make a new file and call it progress.html. Let\u2019s start coding that file.<\/p>\n

\r\n<html>\r\n<head>\r\n\t<title>My Percent Bar Tutorial<\/title>\r\n\t<meta http-equiv="content-type" content="text\/html; charset=iso-8859-1" \/>\r\n\t<script type="text\/javascript" src="js\/prototype\/prototype.js"><\/script>\r\n\t<script type="text\/javascript" src="js\/bramus\/jsProgressBarHandler.js"><\/script>\r\n<\/head>\r\n<\/pre>\n

This section of code simply starts the HTML file and tells it where to grab the javascript files. Make sure you have the file in these directories on your server or it will not work. If you put all your files in the same folder, just simply remove the js\/prototype and the js\/bramus from the two paths.<\/p>\n

\r\n<body>\r\n\t\t<span style="color:#006600;font-weight:bold;">Percent Completed<\/span> <br\/>\r\n\t\t<span class="progressBar" id="element1">0%<\/span>\r\n\r\n\t\t<form name="progress">\r\n<\/pre>\n

Next we have our title and our progress bar. Note the zero percent. This is what value you want the bar to start at. You can change it to any value from 0 to 100 and it will start with that value when the page is opened and\/or refreshed. <\/p>\n

\r\n\t\t<input type="checkbox" name="box1" onclick="CheckValues('progress', 'box1', '7');">\r\n\t\tTask 1 - 7%<br \/>\r\n\t\t<input type="checkbox" name="box2" onclick="CheckValues('progress', 'box2', '8');">\r\n\t\tTask 2 - 8%<br \/>\r\n\t\t<input type="checkbox" name="box3" onclick="CheckValues('progress', 'box3', '4');">\r\n\t\tTask 3 - 4%<br \/>\r\n\t\t<input type="checkbox" name="box4" onclick="CheckValues('progress', 'box4', '18');">\r\n\t\tTask 4 - 18%<br \/>\r\n\t\t<input type="checkbox" name="box5" onclick="CheckValues('progress', 'box5', '9');">\r\n\t\tTask 5 - 9%<br \/>\r\n\t\t<input type="checkbox" name="box6" onclick="CheckValues('progress', 'box6', '6');">\r\n\t\tTask 6 - 6%<br \/>\r\n\t\t<input type="checkbox" name="box7" onclick="CheckValues('progress', 'box7', '8');">\r\n\t\tTask 7 - 8%<br \/>\r\n\t\t<input type="checkbox" name="box8" onclick="CheckValues('progress', 'box8', '11');">\r\n\t\tTask 8 - 11%<br \/>\r\n\t\t<input type="checkbox" name="box9" onclick="CheckValues('progress', 'box9', '16');">\r\n\t\tTask 9 - 16%<br \/>\r\n\t\t<input type="checkbox" name="box10" onclick="CheckValues('progress', 'box10', '13');">\r\n\t\tTask 10 - 13%<br \/>\r\n\t<\/form>\r\n<\/pre>\n

These are all of our checkboxes. You\u2019ll notice that every checkbox is calling a function onclick. This is so that we can determine whether or not the click is checking the box or un-checking the box and therefore adding value to the bar or removing value from it. The function we are calling is CheckValues and we are sending the values of progress (form name), box# (checkbox name), and value (amount to add to the progress bar). You can have as many boxes as you want and they can be whatever value you deem necessary. Obviously, they should all add up to 100% when all selected. I have added text to the site to show the user which box adds which amount to the bar. Then we end the form.<\/p>\n

\r\n\t<!-- STATS -->\r\n\t<script src="\/mint\/?js" type="text\/javascript"><\/script>\r\n\t<script src="http:\/\/www.google-analytics.com\/urchin.js" type="text\/javascript"><\/script>\r\n\t<script type="text\/javascript">\r\n\t\t\/\/ <!&#91;CDATA&#91;\r\n\t\t_uacct = "UA-107008-4";\r\n\t\turchinTracker();\r\n\t\t\/\/ &#93;&#93;>\r\n\t<\/script>\t\r\n<\/body>\r\n<\/html>\r\n<\/pre>\n

This section here is for the author of the tool. It allows them to monitor how many people are using this software (at least those who keep this code in the file). Then we end the body and the html. <\/p>\n

\r\n<SCRIPT LANGUAGE="JavaScript">\r\nfunction CheckValues(Form, CheckBox, Value)\r\n{\r\n\tvar objCheckBox = document.forms[Form].elements[CheckBox];\r\n\tif (objCheckBox.checked == true){\r\n\t\tmyJsProgressBarHandler.setPercentage('element1','+'+Value);return true;\r\n\t}else{\t\r\n\t\tmyJsProgressBarHandler.setPercentage('element1','-'+Value);return true;\t\r\n}\r\n}\r\n<\/script>\r\n<\/pre>\n

The last bit of code is the script to check whether we are checking or un-checking. We initialize the function. Next, we set the checkbox to a variable. Then we check if the box is checked and if it is add the value of the checkbox to the progress bar, and if not we remove the value from the progress bar. Finally we end the script.<\/p>\n\"javascript_progress_bar_03\"<\/a>\n

Once you put the files in the right places and open the html file in a browser your screen should look like this.<\/p>\n\"javascript_progress_bar_04\"<\/a>\n

If you start checking boxes the progress bar will increase (which it does through an animation). <\/p>\n\"javascript_progress_bar_05\"<\/a>\n

Once all the boxes are checked the progress bar will be full. If you un-check any of the boxes it will remove the appropriate value from the progress bar. This concludes this tutorial. I hope you found it helpful and easy to follow. Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"

This tutorial will walk you through Configuring a javascript based progress bar that can triggered by several things. You could have it triggered by how many results are pulled back from a database, or you could have it triggered by the length of a textbox (passwords), or even trigger it by checkboxes that are checked.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[30,46],"tags":[50,49,51,55],"yoast_head":"\nJavaScript Progress Bar<\/title>\n<meta name=\"description\" content=\"This tutorial will walk you through Configuring a javascript based progress bar that can triggered by several things. You could have it triggered by how many results are pulled back from a database, or you could have it triggered by the length of a textbox (passwords), or even trigger it by checkboxes that are checked.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mike Maguire\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/teamtutorials.com\/#website\",\"url\":\"https:\/\/teamtutorials.com\/\",\"name\":\"Team Tutorials\",\"description\":\"Learn something new today\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/teamtutorials.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/teamtutorials.com\/wp-content\/uploads\/2008\/08\/javascript_progress_bar_01.jpg\",\"contentUrl\":\"http:\/\/teamtutorials.com\/wp-content\/uploads\/2008\/08\/javascript_progress_bar_01.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#webpage\",\"url\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar\",\"name\":\"JavaScript Progress Bar\",\"isPartOf\":{\"@id\":\"https:\/\/teamtutorials.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#primaryimage\"},\"datePublished\":\"2008-08-12T05:26:35+00:00\",\"dateModified\":\"2008-10-26T18:45:17+00:00\",\"author\":{\"@id\":\"https:\/\/teamtutorials.com\/#\/schema\/person\/eb38d967529dbe49f7cbe082fd39105b\"},\"description\":\"This tutorial will walk you through Configuring a javascript based progress bar that can triggered by several things. You could have it triggered by how many results are pulled back from a database, or you could have it triggered by the length of a textbox (passwords), or even trigger it by checkboxes that are checked.\",\"breadcrumb\":{\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/teamtutorials.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript Progress Bar\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/teamtutorials.com\/#\/schema\/person\/eb38d967529dbe49f7cbe082fd39105b\",\"name\":\"Mike Maguire\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/teamtutorials.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/36f2aa9a11241ca79ed05e758e36f3cb?s=96&d=mm&r=r\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/36f2aa9a11241ca79ed05e758e36f3cb?s=96&d=mm&r=r\",\"caption\":\"Mike Maguire\"},\"sameAs\":[\"http:\/\/mikemaguire.me\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JavaScript Progress Bar","description":"This tutorial will walk you through Configuring a javascript based progress bar that can triggered by several things. You could have it triggered by how many results are pulled back from a database, or you could have it triggered by the length of a textbox (passwords), or even trigger it by checkboxes that are checked.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar","twitter_misc":{"Written by":"Mike Maguire","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/teamtutorials.com\/#website","url":"https:\/\/teamtutorials.com\/","name":"Team Tutorials","description":"Learn something new today","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/teamtutorials.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#primaryimage","inLanguage":"en-US","url":"http:\/\/teamtutorials.com\/wp-content\/uploads\/2008\/08\/javascript_progress_bar_01.jpg","contentUrl":"http:\/\/teamtutorials.com\/wp-content\/uploads\/2008\/08\/javascript_progress_bar_01.jpg"},{"@type":"WebPage","@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#webpage","url":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar","name":"JavaScript Progress Bar","isPartOf":{"@id":"https:\/\/teamtutorials.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#primaryimage"},"datePublished":"2008-08-12T05:26:35+00:00","dateModified":"2008-10-26T18:45:17+00:00","author":{"@id":"https:\/\/teamtutorials.com\/#\/schema\/person\/eb38d967529dbe49f7cbe082fd39105b"},"description":"This tutorial will walk you through Configuring a javascript based progress bar that can triggered by several things. You could have it triggered by how many results are pulled back from a database, or you could have it triggered by the length of a textbox (passwords), or even trigger it by checkboxes that are checked.","breadcrumb":{"@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/html-tutorials\/javascript-progress-bar#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/teamtutorials.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript Progress Bar"}]},{"@type":"Person","@id":"https:\/\/teamtutorials.com\/#\/schema\/person\/eb38d967529dbe49f7cbe082fd39105b","name":"Mike Maguire","image":{"@type":"ImageObject","@id":"https:\/\/teamtutorials.com\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/36f2aa9a11241ca79ed05e758e36f3cb?s=96&d=mm&r=r","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/36f2aa9a11241ca79ed05e758e36f3cb?s=96&d=mm&r=r","caption":"Mike Maguire"},"sameAs":["http:\/\/mikemaguire.me"]}]}},"_links":{"self":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts\/1624"}],"collection":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/comments?post=1624"}],"version-history":[{"count":0,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts\/1624\/revisions"}],"wp:attachment":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/media?parent=1624"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/categories?post=1624"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/tags?post=1624"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}