我在使用我的网站URL传递变量时遇到问题。在URL中传递php变量
下面的代码:
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
但我想将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;
}
它的工作..任何人都可以告诉我什么问题可能是什么?
谢谢!
这看起来很像JavaScript而不是PHP代码 –
@GeraldSchneider我也注意到了,但是在我看来JavaScript并不是必需的 – Voitcus