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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:17:53+00:00 2026-06-14T05:17:53+00:00

I have a select looking something like this: <select id=address> <option noodd=1-9 noeven=2-6>Address Name

  • 0

I have a select looking something like this:

<select id="address">
  <option noodd="1-9" noeven="2-6">Address Name 1</option>
  <option noodd="3-5" noeven="2-10">Address Name 2</option>
  <option noodd="3-11" noeven="1-5">Address Name 3</option>
</select>

<select id="housenumber">
</select>

Whenever one of the options in #address is selected, I need #housenumber to be filled with the numbers within the ranges of the address selected. So when Address Name 1 is selected, I need #housenumber to look like this:

<select id="housenumber">
  <option>1</option>
  <option>2</option>
  <option>3</option>
  <option>4</option>
  <option>5</option>
  <option>6</option>
  <option>7</option>
  <option>9</option>
</select>

Does anyone have a clever idea how to do that?

UPDATE, what I need is this:

  • A function that finds all equal numbers between the numbers specified in noeven for each option.
  • A function that finds all odd numbers between the numbers specified in noodd for each option.
  • A function that combines those two lists and puts them into option elements
  • A function that appends these option elements to #housenumber whenever the corresponding option in #address is selected
  • 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-14T05:17:54+00:00Added an answer on June 14, 2026 at 5:17 am

    Something like this should do it:

    $('#address').change(function(){
        var $selected = $('option:selected',this);
        var odd = $selected.attr('noodd').split('-');
        var even = $selected.attr('noeven').split('-');
    
        var arr = [];
        for(var o = parseInt(odd[0],10);o<=parseInt(odd[1],10);o+=2){
           arr.push(o);  
        }
    
        for(var e = parseInt(even[0],10);e<=parseInt(even[1],10);e+=2){
           arr.push(e);  
        }
    
        var $housenumber = $('#housenumber');
        $housenumber.empty();
        $.each(arr.sort(function(a,b){return a-b;}),function(i,e){
           $housenumber.append($('<option/>').text(e));
        });
    });
    

    Live example: http://jsfiddle.net/uhwMS/

    A couple of notes:

    1. You should use data-* attributes rather than custom ones. Making your option nodes look like <option data-odd="1-9" data-even="2-6">Address Name 1</option> making reading them safer, eg var odd = $selected.data('odd').split('-');

    2. Your third element has odd numbers for even, giving some strange results. Assume this was just ann error posting the question?

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

Sidebar

Related Questions

I have a select tag that looks like this: <select name=TZSelector id=TheTZSelector> <option>add another
Let's say I have SELECT name FROM table which gives me something like foo
I have a table looking something like this: +-------+-----+ |country|prop1| +-------+-----+ |RO | 1
I'm looking for something like this: Let's say we have a string.. $chk=pie; And
i have select <select id=parentId name=parentId><option value=1>ФАСАДНАЯ ШТУКАТУРКА&lt;BR /&gt;&lt;B&gt;&amp;#0171;STUC-O-FLEX&amp;#0187;&lt;/B&gt;</option> <option value=2>ФОНТАНЫ И САДОВАЯ МЕБЕЛЬ&lt;BR
I tried looking for posts like this one but although many are similar, none
I have a MySQL table that looks something like this: |---ID---|---COUNTER---| | 1 |
I have a table like this id, name, datetime which might store multiple entries
I am looking for something like this but can't figure out the best way
I have a data set that looks something like this: Gender | Age |

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.