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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:25:51+00:00 2026-06-04T22:25:51+00:00

I have a drop down list with decimal values. (formatted as string) <select id=SizeBox>

  • 0

I have a drop down list with decimal values. (formatted as string)

<select id="SizeBox">
   <option id="size_5" value="14.00">14</option>
   <option id="size_6" value="16.00">16</option>
   <option id="size_7" value="18.00">18</option>
   <option id="size_8" value="20.00">20</option>
   <option id="size_9" value="24.00">24</option>
   <option id="size_10" value="28.00">28</option>
   <option id="size_11" selected="selected" value="28.35">28,35</option>
   <option id="size_12" value="36.00">36</option>
</select>

I always take the selected value and save it in a variable:

var backupSize = "28.35";

When the user selected another size and wants to undo his changes, I provide a reset button that should select the backupSize value again.

SelectSize(parseFloat(backupSize).toFixed(2));

function SelectSize(size) {
   $('#SizeBox').val(size);
}

The problem is that using this toFixed method removes my decimal precision and pass the value 28.00 to the SelectSize function. Offcourse, there is no option in my list with this value so the reset function fails.

If i use the SelectSize function without the toFixed(2) part, then values like “20.00” will be passed as “20” and the SelectSize function will also fail to reset the size in the dropdown box.

I’ve searched for function that handle these decimal numbers just like strings but without success so far. How can i solve this?

Thanks for any help!

  • 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-04T22:25:54+00:00Added an answer on June 4, 2026 at 10:25 pm

    Here is something that will work with justabout any value:
    working example: http://jsfiddle.net/4DSNS/2/

    var backupSize = 20
    var backupSize = 28.35
    var backupSize = "28.35"
    var backupSize = "20.00"
    var backupSize = "20"
    var backupSize = "28.35"
    var backupSize = "28,35"
    function SelectSize(size) {
       size = size.toString().replace(',','.');
       parseFloat(size).toFixed(2);
       $('#SizeBox').val(size);
    }
    
    SelectSize(backupSize);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop-down list with numerical values: <select name=a> <option value=1>asdsadas</option> <option value=1>wqecsdc</option>
I have this drop-down list of countries: <select name=country> <option value=>Country...</option> <option value=Afganistan>Afghanistan</option> <option
I have a drop down list <select onchange=alert(this.value);> <option selected=selected value=cat>cat</option> <option value=dog>dog</option> </select>
Suppose I have a drop-down list like: <select id='list'> <option value='1'>Option A</option> <option value='2'>Option
I have a drop down list displaying values in a select tag that I
I have a drop down list on a form with values: Value One Value
I have one drop-down list (<select> <option>) on page with id="coclevel1" . If current
I have a drop down list where users can select a theme for the
I have a drop down list and I want the selected value to put
Basically I have a drop down list which is populated with text and values

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.