Change form action on select option

You can use the onchange event to change the form's action

document.getElementById('store').storeID.onchange = function() {
    var newaction = this.value;
    document.getElementById('store').action = newaction;
};

Here is a jsfiddle with the code.


<form name="store" id="store" method="post" action="" id="FORM_ID" >
    <select name="storeID">
        <option value="/stores/store6.php">6</option>
        <option value="/stores/store10.php">10</option>
    </select>                   
</form>

<script type="text/javascript">
document.getElementById('storeID').onchange = function(){
    document.getElementById('FORM_ID').action = '/'+this.value;
}
</script>

check it out i wish it will work ..


Add to select onchange function

<select name="storeID" onchange='changeAction(this.value)'>

and add to javascript

function changeAction(val){
    document.getElementById('storeID').setAttribute('action', val);
}

This will change action after selected option is changed to selected option value.