views:

206

answers:

2

I have this script on a mafia game where i have 4 worlds/servers I have index.php where i want to login directly to one of the servers by selecting it from a option

I have this code and i need to change form action

<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>

Hope you understood what i need :) see ya

A: 

Its probably best to handle the users selection on the server, and either perform a redirect there or handle the action as needed. But if you really wanted to handle it on the client side you should use javascript. The following should work after including the jQuery library:

$('#server_select').change(function(){
   $(this).parents('form').attr('action', $(this).val());
});

To be more specific add the following code to the head section of your html file.

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"&gt;&lt;/script&gt;

<script type="text/javascript">
  $('#server_select').change(function(){
    $(this).parents('form').attr('action', $(this).val());
  });
</script>
mountainswhim
A: 

can you tell me exactly how to do all these steps ?

eDY