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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:04:45+00:00 2026-05-26T10:04:45+00:00

I have magento store and a product with a dropdown with 30 options of

  • 0

I have magento store and a product with a dropdown with 30 options of a range of sizes. I also have a text box which I need to reference the dropdown and select a value dependant on what is written in the box.

So for example if someone types in 105 in the text box I need jQuery to automatically select the value of 100-110 in the dropdown (which in turn triggers an ajax change of price which is already in place).

Is this possible in jQuery and what functions should I be looking at?

Edit: jQuery code so far…

<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery("#options_483998_text").keyup(function(){
        var value = jQuery("#options_483998_text").val() * 1;
        var jQueryselect = jQuery("select#attribute592");
        var optionValue = "";
        jQuery('option', jQueryselect).each(function(){
            var range = jQuery(this).text().match(/\d+/g);
            if(range && value >= range[0] && value <= range[1]){
                optionValue = this.value;
                return false;
            }
        });

        jQueryselect.val(optionValue);jQueryselect.change();

    });
    jQuery("#options_483997_text").keyup(function(){
        var value = jQuery("#options_483997_text").val() * 1;
        var jQueryselect = jQuery("select#attribute593");
        var optionValue = "";
        jQuery('option', jQueryselect).each(function(){
            var range = jQuery(this).text().match(/\d+/g);
            if(range && value >= range[0] && value <= range[1]){
                optionValue = this.value;
                return false;
            }
        });

        jQueryselect.val(optionValue);jQueryselect.change();
    });


});
</script> 
  • 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-26T10:04:45+00:00Added an answer on May 26, 2026 at 10:04 am

    Loop through each option element, and check whether the given value is within the range of the option value. Fiddle: http://jsfiddle.net/QFfLB/2/

    var value = $("#inputBox").val() * 1; //Convert to number, example: 105
    var elem;
    $('select option').each(function(){
        var val = $(this).val();    //Example:  100-110
        var range = val.split("-"); //Example: [100,110]
        if(val >= range[0] && val <= range[1]){
            elem = this;
            return false;
        }
    });
    elem = $(elem); //If existent, elem will be the jQuery object,
                    // representing the option element
    

    This code assumes all option values to be in the following format: x-y (where x and y are numbers). If your code contains something like 120+, the code has to be modified. If this is the case, post a comment with a link to your relevant code, and I will have a look at it.

    Update – Fiddle: http://jsfiddle.net/QFfLB/4/
    Use the .text() method to get the label of an option. Then, use .match(/\d+/g) to find the number values:

    var value = $("#inputBox").val() * 1;    //Get number
    var $select = $("select#attribute592");  //<select> element
    var optionValue = "";                    //Default value
    $('option', $select).each(function(){
        var range = $(this).text().match(/\d+/g); //Range
        if(range && value >= range[0] && value < range[1]){
            optionValue = this.value;
            return false;
        }
    });
    $select.val(optionValue);                //Set new option value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Magento store which needs different prices for each site, which restricts
I have a Magento store which contains over 2500 categories. I have so many
We have a Magento store on 1.5.0.1 Community Edition which uses configurable products with
We have a magento store which mainly features the contents and it has only
I am building a Magento extension, in which I need to have the following
In my Magento store I currently have Flat Catalog Product turned Off because it
I have multi-store Magento installation, and different product prices are set in different stores.
I have a product page in a Magento store and I'm trying to implement
I have a magento store where sometimes customers make phone orders, so I enter
I am creating a store in Magento and have a weird issue with IE6

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.