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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:40:11+00:00 2026-06-06T02:40:11+00:00

I am developing a rate module, figuring out how much is spent for how

  • 0

I am developing a rate module, figuring out how much is spent for how many minutes they get with a calling card. For exaple, calling to South Africa costs 0.015 a minute. I would like to perform the following math:

SouthAfrica * minutes. Or in this case: 0.015*200 and get $3 as a result.

My question is: do I put the following value either in:

Code version 1:
HTML:

   <option value="0.015">South Africa</option>

JS:

   var inputCountries =$('#CountryName').val();
   var inputMinutes = $('#minutes').val();
   var result = parseInt(inputMinutes)*parseFloat(inputCountries);

Code version 2:
HTML:

    <option value="SouthAfrica">South Africa</option>

JS:

    var SouthAfrica = 0.015;
    var inputCountries =$('#CountryName').val();
    var inputMinutes = $('#minutes').val();
    var result = parseInt(inputMinutes)*parseFloat(inputCountries);

Code version 3:
HTML:

    <option value="SouthAfrica">South Africa</option>

JS:

    var inputCountries =$('#CountryName').val(
           SouthAfrica = 0.015;
      );
    var inputMinutes = $('#minutes').val();
    var result = parseInt(inputMinutes)*parseFloat(inputCountries);

This is my first JavaScript project, and learning as I go, so I would appreciate any sources to explaining why the above code works/doesn’t work. Here is the rest of my code for reference.

NOTE: Please do not correct the REST of my code, I am still researching and learning. However, any hints or resources to figure out the rest of the code would be very much appreciated. My focus of this topic is to the assigning value of each country. I have tried to figure out how to solve the problem using several different resources, but have come up empty. Thank you for your time!

HTML:

    <form name="calculator">
    <!--
    Countries
    -->
    <label><span><!--[Write as something else]-->Where do you want to call?</span>
    </label>

    <select id="CountryName" class="rates">
    <option>Select...</option>
    <option value=" ?? ">South Africa</option <!--This list is truncated to keep the post short-->
    </select>
    <label>Minutes to call</label>
    <input id="minutes" type="text" class="rates" /><br />

    <input type="button" name="submit" id="submit" value="Submit" />

    <input type="button" name="clear" id="clear" value="Clear" />
    <br />
    </form>
    <div id="RatesResult">
    <p>
    <span id="total"></span> for 
    <span id="afterMin"></span> minutes. <!--This section, #afterMin, is still being worked on, any hint/resources on how to print what user wrote in #minutes into this section would be appreciated -->

    </p><br />
    </div>
    </div>

JS:

       $(document).ready(function() {
    $('#submit').submit(function() {
 var total = 0;
     var SouthAfrica = 0.015, Canada = 0.015 ; //truncated list             
    var inputCountries =$('#CountryName').val();
var inputMinutes = $('#minutes').val();
var result = parseInt(inputMinutes)*parseFloat(inputCountries);
$('#total').html(formatCurrency(result));
        });
   });
  • 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-06T02:40:12+00:00Added an answer on June 6, 2026 at 2:40 am

    The simplest answer, for you, is to create an object like this: (note that all objects in javascript are effectively hashmaps/dictionary<string,value> types.

    var rates = {
      'SouthAfrica': 0.0015,
      'USA' : 0.0001,
      .....
      'France' : 0.0005
    }
    
    //HTML
    <option value="SouthAfrica">South Africa</option>
    <option value="USA">United States of America</option>
    

    And then when you get the val from the select, like $('#CountryName').val(); you can do a lookup on the rates object, like so:

    var countrySelected = $('#CountryName').val();
    var rate = rates[countrySelected];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While developing, I will sometimes try a technique or method that doesn't pan out
I'm developing a foreign exchange rate app that downloads data from a specific url
I am developing an extension that will allow the user to rate the page
I am developing a rails application where I need a success rate system similar
Im developing a reminder app. So my client want to set a rate this
I am developing a bespoke pricing matrix for a client, they have codes to
Developing a game with AndEngine GLES2 I am having an issue trying to change
Developing locally in MAMP and need Sphinx to work with MAMP's MySQL. Basically hitting
Developing a project of mine I realize I have a need for some level
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart

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.