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

  • SEARCH
  • Home
  • 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 7752205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:44:24+00:00 2026-06-01T11:44:24+00:00

How should I go about pushing the value of a variable to an input

  • 0

How should I go about pushing the value of a variable to an input value with Javascript? I know is possible to set other element attributes with setAttribute but I can’t get anything to set in the “value”.

Here’s the current javascript function:

function testfunc(){
    document.getElementsByTagName("meter")[0].setAttribute("value", "2000");   
}​

And the HTML:

<!doctype html>
<head>
<meta charset="utf-8">
<title>untitled</title>
</head>
<body>

<div id="container">
    <button onclick="testfunc()">Find my elevations</button>  
    <meter value="900" min="0" max="5280" id="high">500/5280</meter>
</div> 

</body>
</html>

​

What i’d like to do is replace the current set value of 900 with the testfunc() value of 2000. The 2000 is completely arbitrary as it will be a dynamically generated number in the live app.

  • 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-06-01T11:44:25+00:00Added an answer on June 1, 2026 at 11:44 am

    HTML 5: 4.10.17 The meter element suggests that you can just do

    document.getElementById("high").value = /* float value between min and max */
    

    The relevant portions of that spec are

    The following inequalities must hold, as applicable:

    • minimum ≤ value ≤ maximum
    • minimum ≤ low ≤ maximum (if low is specified)
    • minimum ≤ high ≤ maximum (if high is specified)
    • minimum ≤ optimum ≤ maximum (if optimum is specified)
    • low ≤ high (if both low and high are specified)

    …

    The value IDL attribute, on getting, must return the actual value. On setting, the given value must be converted to the best representation of the number as a floating point number and then the value content attribute must be set to that string.

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

Sidebar

Related Questions

Are there any VC++ settings I should know about to generate better PDB files
Are there any open-source libraries that all programmers should know about? I'm thinking something
What are all the common undefined behaviours that a C++ programmer should know about?
Are there any criteria one should know / think about before deciding to go
I know that a UINavigationController has good view pushing methods. But let's say that
We should forget about small efficiencies, say about 97% of the time: premature optimization
Are there any big differences a developer should care about?
I'm wondering that how much worried I should be about data types. I can
As Knuth said, We should forget about small efficiencies, say about 97% of the
Two quick questions if I may, is this how I should go about taking

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.