请原谅这个新手用户!我正在尝试创建一个表格,用户可以在其中从音乐会节目列表中进行选择,然后为所选节目选择一个日期(从 2 个或 3 个相关日期中)。同一组下拉菜单必须再重复 3 次。这是一个部分季节订阅包,其中顾客可以选择 6 个节目中的 4 个以及每个节目的所需日期,所有这些信息都需要发布到 Paypal 以进行处理/购买。
请查看此测试页面:http ://early-music.org/Test_forTzN.html和此 jsfiddle.net 页面:jsfiddle.net/saraswati/v6Pur/31
正如在网页上看到的那样,我的脚本适用于“Concert 1”,但不适用于 Concerts 2、3 和 4。在 jsfiddle 页面上,即使 Concert 1 也不起作用。
感谢您的帮助!
这是代码:
<script type="text/javascript">
var progamsAndDates = {};
progamsAndDates['TUDORS'] = ['Sept. 15', 'Sept. 16'];
progamsAndDates['NOCHES'] = ['Oct. 20', 'Oct. 21'];
progamsAndDates['CHRISTMAS'] = ['Dec. 14', 'Dec. 15', 'Dec. 16'];
progamsAndDates['CELTIC'] = ['Jan. 26', 'Jan. 27'];
progamsAndDates['UNREQUITED'] = ['Mar. 02', 'Mar. 03'];
progamsAndDates['SECRET'] = ['Apr. 20', 'Apr. 21'];
function ChangeDateDropList (id) {
var programDropList = document.getElementById ("program"+id);
var dateDropList = document.getElementById ("date"+id);
var selProgram = programDropList.options[programDropList.selectedIndex].value;
// remove all dates
while (dateDropList.options.length) {
dateDropList.remove (0);
}
// add new dates
var dates = progamsAndDates[selProgram];
if (dates) {
for (var i=0; i < dates.length; i++) {
var date = new Option (dates[i], i);
dateDropList.options.add (date);
}
}
}
</script>
<tr id=row2>
<td><input type="hidden" name="os0" value="Concert 1"><body onload="ChangeDateDropList ();">
<select id="program" onchange="ChangeDateDropList();">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date">
</select>
</body>
</td>
<td><input type="hidden" name="os1" value="Concert 2"><body onload="ChangeDateDropList ();">
<select id="program1" onchange="ChangeDateDropList(1);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date1">
</select>
</body>
</td>
<td><input type="hidden" name="os2" value="Concert 3"><body onload="ChangeDateDropList ();">
<select id="program2" onchange="ChangeDateDropList(2);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date2">
</select>
</body>
</td>
<td><input type="hidden" name="os3" value="Concert 4"><body onload="ChangeDateDropList ();">
<select id="program3" onchange="ChangeDateDropList(3);">
<option value="" selected="selected">Select a Program</option>
<option value="TUDORS">The Tudors</option>
<option value="NOCHES">Noches, Noches</option>
<option value="CHRISTMAS">Christmas Eurotour</option>
<option value="CELTIC">Celtic Trinity</option>
<option value="UNREQUITED">Unrequited Love</option>
<option value="SECRET">Secret No More</option>
</select>
<select id="date3">
</select>
</body>
</td>
</tr>
</table>
<br>
<center>
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_cart_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</center>