本文介绍了在选择选项上更改表单操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
< form name =storeid =storemethod =postaction =>
< select name =storeID>
< option value =/ stores / store6.php> 6< / option>
< option value =/ stores / store10.php> 10< / option>
< / select>
< / form>
现在我想要表单操作,使用select选项值。例如:
如果选择了选择1,请使用下列表单操作/stores/store6.php
解决方案
<$ p $ ($'c $ c> document.getElementById('store')。storeID.onchange = function(){
var newaction = this.value;
document.getElementById('store')。action = newaction;
};
您可以使用 onchange
事件来更改表单的操作
<$ p $ ($'c $ c> document.getElementById('store')。storeID.onchange = function(){
var newaction = this.value;
document.getElementById('store')。action = newaction;
};
是一个jsfiddle的代码。
I want to change the form action based on a selection value.
Hi Guys,
<form name="store" id="store" method="post" action="">
<select name="storeID">
<option value="/stores/store6.php">6</option>
<option value="/stores/store10.php">10</option>
</select>
</form>
Now i want the form action, to use the select option value. For example:
If Selection 1 is selected, use the folowing form action /stores/store6.php
解决方案
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.
这篇关于在选择选项上更改表单操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
08-15 17:16