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

  • Home
  • SEARCH
  • 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 7080121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:45:21+00:00 2026-05-28T06:45:21+00:00

I am changing a variable based on the value selected from a dropdown. I

  • 0

I am changing a variable based on the value selected from a dropdown. I have something similar working with an if/else statement but when I try it with switch I can not get it to work. I made a fiddle of this here

html :

<select class="heiSelect">
            <option value='3924'>6'1"</option>
            <option value='3923'>6'2"</option>
            <option value='3922'>6'3"</option>
            <option value='3921'>6'4"</option>
            <option value='3920'>6'5"</option>
            <option value='3919'>6'6"</option>
            <option value='3918'>6'7"</option>
            <option value='3917'>6'8"</option>
            <option value='3916'>6'9"</option>
            <option value='3915'>6'10"</option>
     </select>
<h1>Results : </h1>

javascript:

$(function() {
    var hvd = 0;
    $('.heiSelect').change(function() {
        var heiValue = $('.heiSelect').val();
        switch (heiValue) {
        case 3915:
            hvd = 4294964526;
            break;
        case 3916:
            hvd = 4294964528;
            break;
        case 3917:
            hvd = 4294964529;
            break;
        case 3918:
            hvd = 4294964406;
            break;
        case 3919:
            hvd = 4294964495;
            break;
        case 3920:
            hvd = 4294964494;
            break;
        case 3921:
            hvd = 4294964493;
            break;
        case 3922:
            hvd = 4294964492;
            break;
        case 3923:
            hvd = 4294964491;
            break;
        case 3924:
            hvd = 4294964490;
            break;
        }
        $('h1').append(heiValue + " + " + hvd + ", ");

    });
});

Can you see the problem?

  • 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-28T06:45:22+00:00Added an answer on May 28, 2026 at 6:45 am

    The value is a string, while you tested them against numbers.

    To fix it, either parse the string into integer:

    var heiValue = parseInt($('.heiSelect').val(), 10);
    

    or use strings in the cases:

    case '3915': 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chunk of code where it appears that a variable is changing
changing a static resource during runtine is something that sounds not possible. I have
I know that this question seems illogical, but I have to try, and I
(this isn't duplicate of Changing Django settings variable dynamically based on request for multiple
When changing the selected item in a ListBox, I'm getting a weird error where
When changing the VCS for my project FakeItEasy from SVN to Mercurial on Google
I have a skin that's base clas is GraphicRectangularBorderSkin (from degrafa). I'm using it
Probably a rookie error, but i'm getting something strange. i'm trying to weave a
I'm comfortable with determining connection strings by environmental variable in general, but the connection
working on a simple C++ pointer-based stack program. I am attempting to print a

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.