我有了這個選擇在我的代碼,選擇一個章節中,我要顯示(image here)數量:更新選擇值(HTML)的按鈕
<select name="select" onchange="javascript:sliders[0].goTo(value);">
<?php for($i=1; $i<$row['nbChapitre']+1; $i++){ ?>
<option value="<?php echo $i; ?>">Chapitre <?php echo $i ;?></option>
<?php } ?>
</select>
當我更新它,它的工作原理完美(滑塊移動到問題章節)。 但是,當我使用它有這樣的代碼按鈕(下一個和以前):
<a href="javascript:sliders[0].goToPrev()"> < </a>
<a href="javascript:sliders[0].goToNext()"> > </a>
作品背後的滑塊,但選擇不更新,我不知道該怎麼做.. 。
感謝您的幫助。
編輯:嗯,我覺得我已經給你看我的滑塊功能:
var Slider = function() { this.initialize.apply(this, arguments) }
Slider.prototype = {
initialize: function(slider) {
this.ul = slider.children[0]
this.li = this.ul.children
this.ul.style.width = (this.li[0].clientWidth * this.li.length) + 'px'
this.currentIndex = 0
},
goTo: function(index) {
if (index < 0 || index > this.li.length - 1)
return
this.ul.style.left = '-' + (100 * index) + '%'
this.currentIndex = index
},
goToPrev: function() {this.goTo(this.currentIndex - 1)},
goToNext: function() {this.goTo(this.currentIndex + 1)}};
我試着像你說的對它們進行編輯,但沒有什麼變化......
嗯,我認爲我的上一個和下一個功能沒有得到我的當前選擇的價值,因爲當我手動改變我的選擇值(爲例:第3章) Next函數將不起作用,但Previous函數將用於chapter2,然後下一個函數將再次運行。這很奇怪,我不解釋它。 –