我有一个select
看起来像这样的东西:
<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. 所以当Address Name 1
被选中时,我需要#housenumber
看起来像这样:
<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>
有谁知道如何做到这一点?
更新,我需要的是:
noeven
一个函数,用于查找每个中指定的数字之间的所有相等数字option
。noodd
查找每个中指定的数字之间的所有奇数的函数option
。- 组合这两个列表并将它们放入
option
元素的函数 - A function that appends these
option
elements to#housenumber
whenever the correspondingoption
in#address
is selected