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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:42:51+00:00 2026-06-17T17:42:51+00:00

This should be a fairly easy problem, but I don’t know how to solve

  • 0

This should be a fairly easy problem, but I don’t know how to solve it and haven’t found any appropriate answer to what I’m trying to do.

I have an html file with some text that, in very simple terms, has a string and two radio buttons. So something like this:

    <html>
    <head>
      <title>Some title</title>
      <script src="jquery.js"></script>
    </head>
    <body>

      <div id="main">
         <p> 10 GB </p>
      </div>

      <div class="radioButtons" style="width: 100%">
        <p><input type="radio" name="radioLessGB" value="Less" align="absmiddle"/> I want less gigabytes(-3GB) </p>
            <p><input type="radio" name="radioMoreGB" value="More" align="absmiddle"/> I want more gigabytes (+5GB)</p>
      </div>
   </body>
   </html>

I need a way to update the value of the text (i.e. “10 GB”) depending on the radiobutton that is selected. In particular, when the user selects the first radio button the integer value in the string above should go down by 3 right away (i.e. “10 GB” – 3 = “7 GB”), and if the user selects the second radio button, the integer value should add 5 (i.e. “10 GB” + 5 = “15 GB”).

To do this I guess I have to parse the string “10 GB” to get the Integer value and then add or subtract depending on the radiobutton chosen. Then update the string with the result.
I don’t want the user to click on some kind of “submit” button, the update of the number should be done ‘on-the-fly’ as the user toggles between radiobuttons.

I think this could be done with jQuery, I just don’t know the way about it. Could someone more experienced help with sample code for a simple solution?!?

Thanks!!

  • 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-17T17:42:52+00:00Added an answer on June 17, 2026 at 5:42 pm

    Using jQuery, you can simply do it as follows. try the DEMO HERE

    $("input").change(function() {
        $("#main").text((10 + parseInt($(this).val())) + " GB");
    });
    

    If you need to do this in pure javascript, use the following. try DEMO HERE

    function valChanged(ele) {
        document.getElementById('main1233').textContent = (10 + parseInt(ele.value)) + " GB";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is fairly easy but I just don't know how to solve it.
Okay, this should be a fairly easy question I think, but haven't been able
I know this should be fairly easy but I can't quite figure it out
This should be a fairly simple question to answer, but I am interested to
I think this should be fairly easy but I'm not familiar with how it's
So I'm new to Arrays, but I think this should be fairly easy, I
This should be fairly easy, but I'm getting a headache from trying to figure
I'm fairly sure there should be an elegant solution to this (in MATLAB), but
This seems like it should be fairly simple, but for some reason I can't
This should be fairly easy. I'm following along with a fairly outdated video course

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.