Web サイトの URL を使用して変数を渡す際に問題が発生しています。
コードは次のとおりです。
function sort(form) {
var Page = "?";
var iweek = form.listWeeks.SelectedIndex;
var week = form.listWeeks.options[iweek].value;
var month = form.listMonth.selectedIndex+1;
var iyear = form.listYear.selectedIndex;
var year = form.listYear.options[iyear].value;
var URL = Page + "week=" + week + "&month=" + month + "&year=" + year;
window.location = URL;
return false;
}
この関数を参照する送信ボタンをクリックすると、URL が次のように変わります。
http://localhost/test.php?listWeeks=1&listMonth=August&listYear=2010&Submit=Select
しかし、URLを次のように変更したいと思います:
http://localhost/test.php?week=1&month=8&year=2010
奇妙な部分は、コードを次のように変更したときです。
function sort(form) {
var Page = "?";
//var iweek = form.listWeeks.SelectedIndex;
//var week = form.listWeeks.options[iweek].value;
var month = form.listMonth.selectedIndex+1;
var iyear = form.listYear.selectedIndex;
var year = form.listYear.options[iyear].value;
var URL = Page + "month=" + month + "&year=" + year;
window.location = URL;
return false;
}
それは動作します..誰か問題が何であるか教えてください。
ありがとう!