既然你标记你的问题的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