我在使用我的网站的 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;
}
当我单击引用此功能的提交按钮时,网址更改为:
http://localhost/test.php?listWeeks=1&listMonth=August&listYear=2010&Submit=Select
但我想将网址更改为:
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;
}
它有效..谁能告诉我问题可能是什么?
谢谢!