Change form action on select option

前端 未结 4 796
死守一世寂寞
死守一世寂寞 2020-12-03 18:13

I want to change the form action based on a selection value.

Hi Guys,

4条回答
  •  北海茫月
    2020-12-03 19:09

    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.

提交回复
热议问题