既然你標記你的問題的jQuery,我假定你的地方使用它在你的頁面,讓你改變你的HTML這樣的:
<select name="testselect" id="testselect">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
,並添加到您的通話$(document).ready(..);
捕獲對該下拉菜單的更改,如下所示:
$(document).ready(function() {
$('#testselect').change(function() {
// POST the changed value to a method in a controller that can accept
// a parameter and that'll set the session variable for you
$.post("http://location/to/controller/method/",
{ testselect: this.value },
'html'
);
});
});
您的意思是預選了一個值嗎? – Norse 2012-04-08 19:40:30
不,我已經預先選擇了值,但是如果用戶在下拉列表中選擇了其他選項,我希望它能夠再次更改會話全局。 – 2012-04-08 19:41:34
看,你需要提供更多信息;在用戶更改提交表單之前必須發生的下拉值之後,必須發生什麼?如果是這樣,那麼你需要使用JavaScript來捕獲這個。 – stealthyninja 2012-04-08 21:10:24