我試圖從我的JSP中刪除JavaScript。目前我正在使用類似這樣的內容來根據下拉列表中的選擇轉發到我需要的頁面。根據不使用JavaScript的下拉列表中的選擇轉到新頁面
function STFS() {
var url = document.stform.typeOptions.options[document.stform.typeOptions.selectedIndex].value;
if (url!=0) {
window.location=url;
}
}
我該如何在不使用javascript的情況下做同樣的事情。 我嘗試設置window.location的在如下的「選擇的onChange」:
<select name="typeOptions" onChange="window.location=this.options[this.selectedIndex].value;">
但是,當我提交表單,它並沒有去預期的URL。我肯定錯過了什麼。 這是一個portlet環境,URL相對較長。 任何幫助表示讚賞。由於
你知道在onChange中這樣做仍在使用Javascript,對不對? – Robert 2011-05-03 14:50:35
但你在onChange屬性中嘗試的也是Javascript!? – DanielB 2011-05-03 14:51:38
ummm通過使用onChange事件(更不用提整個window.location位,並使用dom元素來查找您的url值),您正在使用javascript。有沒有一個特定的原因,你不想使用js?你用這種方法試圖完成什麼? – scrappedcola 2011-05-03 14:53:24