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 7279073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:58:20+00:00 2026-05-28T22:58:20+00:00

I have a case where I’d like to be able to allow the users

  • 0

I have a case where I’d like to be able to allow the users to change their units system. In doing so I would have to go through the entire page and:

a) change the units description from text and
b) convert the current values to the new units.

The first part I can achieve ok using getElementById and innerHTML. Its the second part I am having difficulty with

Example – I have two entries with units of “GIIP (BCF):” and values of 235 and 100 respectively;

<table id="table2">
  <tr><input id="calc" type="button" value="Test Convert" onClick="conversion();" />
  <td class="leftcol" id=test_units1>GIIP (BCF):</td>
<td><input id=test_value1 size="7" type="number" value="235"> </td>     
  <td class="leftcol" id=test_units2>GIIP (BCF):</td>
 <td><input id=test_value2 size="7" type="number"  value="100" > </td></table>

When I click the button, the following executes (where for the example I want to change the units description and simply double the existing value);

    function conversion() {
for (var i = 1, e; e = document.getElementById("test_units" + i); ++i)
e.innerHTML = "m<sup>3</sup>";
convert_values();
}

function convert_values() {
    for (var i = 1, e; e = parseFloat(document.getValueById("test_value" + i)); ++i)
var val = (e*2).toString();
e.innerHTML = val;
}

The units description converts OK, but the values are unaffected. Can anyone suggest a method to convert the values in a more elegant fashion (or indeed at all!). Bear in mind that I’ll have many of these conversions to do on any one page/form.

  • 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-28T22:58:21+00:00Added an answer on May 28, 2026 at 10:58 pm

    To retrieve the value of an input object, you use element.value where element is a reference to the input tag. To set the value of an input, you use element.value = newValue;. You don’t use .innerHTML for either. Also, in your code, you are treating e as the value in one place and the element in another place.

    So, you can do it like this:

    function convert_values() {
        for (var i = 1; i < 2; i++)
            var obj = document.getElementById("test_value" + i);
            obj.value = Number(obj.value) * 2;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a case where the operator had to change things manually through management
I have a case where I would like to catch an update event on
I have a case here that I would like to have some opinions from
I have a case where a 3rd party ad is bleeding through my modal
how can i optimized this code? i dont like to have case statement, is
A system I, lamentably, have to use everyday has all caps case sensitive user
I have a case that uses view inheritance, and my code looks essentially like:
I have a case statement that goes a little something like this: case @type
I have this case (a JSON string returned by my server): {success: true, users:
I have a Case-When clause like this; (CASE WHEN A.YAZ_ADRES IS NULL THEN (B.IS_ADRES1

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.