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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:01:19+00:00 2026-06-11T18:01:19+00:00

This is a simple dropdown with values. I’m trying to pull the values as

  • 0

This is a simple dropdown with values. I’m trying to pull the values as currency then add.

The values aren’t being added (1+1=2 or 1+2=3) but instead are concatenating (1+1=11 or 1+2=12). Where am I going wrong here?:

<script>
    function displayResult()
    {
        var strm=document.getElementById("matt").options[document.getElementById("matt").selectedIndex];
        var t=strm.text.search("\\\$");
        var strb=document.getElementById("box").options[document.getElementById("box").selectedIndex];
        var b=strb.text.search("\\\$");
        var x=strm.text.substr(t+1);
        var y=strb.text.substr(b+1);
        var math= x + y;

        alert(strm.text.substr(t+1));
        alert(strb.text.substr(b+1));
        alert(math);
    }
</script>

<form>
    Select #1:
    <select id="matt">
        <option>$1.00</option>
        <option>$2.00</option>
    </select>

    <br />
    Select #2:
    <select id="box">
        <option>$3.00</option>
        <option>$4.00</option>
    </select>

</form>

<button type="button" onclick="displayResult()">Display index</button>
  • 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-11T18:01:20+00:00Added an answer on June 11, 2026 at 6:01 pm

    Use parseInt() to cast your strings as integers.

    var math= parseInt(x,10) + parseInt(y,10);
    

    See https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/parseInt

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

Sidebar

Related Questions

I have a simple dropdown menu: <form class=feedmenu align=center> <select onchange=showRSS1(this.value)> <option value=>Select an
I have a simple dropdown menu and I'd like to have this menu close/hide
This simple script should theoretically check the form for errors and then print any
This simple regex matching returns a string instead of an object on every browser
This simple problem is kiling me. I posted something earlier about trying to clean
I have a fairly simple problem. I have a select dropdown with values 1
I think this should be a simple thing but for some reason all my
tried to create simple dropdown in ruby with values from the database - like
This simple query session = com.jthink.songlayer.hibernate.HibernateUtil.getSession(); Query q = session.createQuery(recNo from SongChanges); giving this
This simple example fails to compile in VS2K8: io_service io2; shared_ptr<asio::deadline_timer> dt(make_shared<asio::deadline_timer>(io2, posix_time::seconds(20))); As

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.