我在黑手党游戏中有这个脚本,我有4个世界/服务器。我有index.php,我想通过选项
直接登录到其中一个服务器<form action="/ro1/index.php?action=login" method="post">
<input id="user" name="user" class="text" type="text" value="Name"/><br>
<input name="clear" type="hidden" value="true" />
<input id="password" name="password" type="password" value="Pass"/>
<select id="server_select" class="server_select" name="server">
<option value="/ro1/index.php?action=login" selected >World 1</option>
<option value="/ro2/index.php?action=login">World 2</option>
<option value="/ro3/index.php?action=login">World 3</option>
<option value="/ro4/index.php?action=login">World 4</option>
</select>
<input type="image" src="graphic/index/login1.png" name="submit">
</form>
希望你明白我的需要。
答案 0 :(得分:0)
最好处理服务器上的用户选择,并在那里执行重定向或根据需要处理操作。但如果你真的想在客户端处理它,你应该使用javascript。包含jQuery库之后,以下内容应该有效:
$('#server_select').change(function(){
$(this).parents('form').attr('action', $(this).val());
});
更具体地说,将以下代码添加到html文件的head部分。
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$('#server_select').change(function(){
$(this).parents('form').attr('action', $(this).val());
});
</script>