Hi,
When a form action URL was changed dynamically, when the form submit, it will still use the default action URL, anybody know why? Please see a simple example below:
<form action="test.php" method="get" id="test">
<select name="id" onChange="formSubmit(this)">
<option value="abc">abc</option>
<option value="xyz">xyz</option>
</select>
</form>
<script type="text/javascript">
function formSubmit(element){
var url = $("#test").attr("action", url);
var newParam = "&new=123";
url += "?" + element.name + "=" + element.value + newParam;
//e.g. formurl now = 'test.php?id=xyz&new=123';
$("#test").attr("action", url);
$("#test").submit();//the form will submit to test.php?id=xyz instead of the new URL
}
</script>
Thx.