我敢肯定这真的很简单,但我似乎无法让它工作。我有一个“时间”选择列表,每个选项都有一个“rel”数字。如果用户更改时间选择,我希望根据所选内容显示一个新的选项列表。如果这有意义吗?
这是我的第一个选择:
<select name="time" id="time">
<option value="7:00am" rel="10">7:00am</option>
<option value="12:30pm" rel="16">12:30pm</option>
</select>
如果用户选择上午 7:00,我想要一个新的选项列表(使用 jquery)来提供从 1 到 10 的选项。像这样:
<select name="quantity" id="quantity">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
............................
<option value="10">10</option>
</select>
这是我到目前为止所拥有的...
<script type="text/javascript" language="javascript">
jQuery("#time").change(function(){
var positions = jQuery("#time :selected").attr("rel"); //this grabs the rel from time
//this is where it should create a list of options to append(??) to the select list..
jQuery("#showQuantity").show(); //this shows the hidden field for quantity
});
</script>
我希望这是有道理的,但我坚持下去。先感谢您 :)