申し訳ありませんが、まだ JQuery に夢中です。このような選択可能なulliリストを作成するのに非常に役立ちました
$(document).ready(function(){
$('.selectoption li').not(':first').hide();
$('.prev, .next').click(function() {
// Determine the direction
var dir = $(this).hasClass('prev') ? 'prev' : 'next';
// Get the li that is currently visible
var current = $('.selectoption li:visible');
// Get the element that should be shown next according to direction
var next = dir == 'prev' ? current.prev('li') : current.next('li');
// If there's no more in that direction, select first/last
if(next.size() == 0) {
next = dir == 'prev' ? $('.selectoption li:first') : $('.selectoption li:first');
}
// Hide them all..
$('.selectoption li').hide();
// And show the new one
next.show();
return false;
});
});
しかし、選択したliの値をテキストフィールドに追加して、フォーム内で使用できるようにするにはどうすればよいですか.liリストがフォームの外にあるため、この機会にAjaxなどを使用することはできません.
また、ページにこれらのulliが3つまたは4つある場合、次/前のボタンがそれらが適用されるulliでのみ機能するように上記のコードをラップするにはどうすればよいですか。
前もって感謝します