Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:14:29+00:00 2026-05-31T16:14:29+00:00

I am trying to create a dynamic bar in HTML using javascript. I have

  • 0

I am trying to create a dynamic bar in HTML using javascript.
I have create the button but cannot seem to pass the value over to the progress bar.
Can someone please help me? thanks!

<button onclick="increase()">Add</button> 
<button onclick="decrease()">Minus</button> 
<input type="text" id="tb"> 
<script type="text/javascript"> 
var value = 0 document.getElementById("tb").value = value; 
function increase(){ 
  this.value = value + 1; document.getElementById("tb").value=value;     
} 
function decrease(){ 
  this.value = value - 1; document.getElementById("tb").value=value; 
} 
document.write("<div class='meter'><span style='width: 30%'></span> </div>");
document.write("<input type='text' id=\"tb\">"+value +" </input>"); 
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:14:30+00:00Added an answer on May 31, 2026 at 4:14 pm

    It’d be easier to do this in jQuery, but here it goes with POJS:

    js:

    var value = 0, 
    tb = document.getElementById("tb"),
    progress = document.getElementById("progress"); //store these, it's better
    function increase(){ 
      value++;// same as value += 1, but better
      if(value>=100) value = 100;//keep it under 100%
      tb.value = value;// set the value of the text field     
      progress.style.width = value + "%";// set the width of the progress bar
    } 
    function decrease(){ 
      value--;
      if(value<=0) value = 0;//keep it over 0%
      tb.value = value; 
      progress.style.width = value + "%";
    } 
    

    document.write is janky, so I ditched that & put the bar in the markup.

    html:

    <button onclick="increase()">Add</button> 
    <button onclick="decrease()">Minus</button> 
    <input type="text" id="tb"> 
    <div id='meter'><div id='progress'></div></div>
    

    css:

    ​#meter {border:1px solid #000;width:100px}
    #progress {background:#333;height:10px;width:0%}​
    

    fiddle: http://jsfiddle.net/sw95b/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create two dynamic dates in html/javascript/jquery. I want the dates
I am trying to create dynamic menus from the database using the following example
I am trying to create a dynamic hyperlink that depends on a value passed
I'm trying to create a dynamic grid using ExtJS. The grid is built and
I am trying to create some dynamic html out of some data from db.
i am trying to create a dynamic multioption select using dynamic values for a
I have application like where i can create dynamic tabs. and delete cross bar
I'm trying to create a bar with a dynamic horizontal width. The backgrounds are
I am trying to create dynamic excel sheet, with the help of php using
So here is the problem: I am trying to create dynamic buttons that have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.