form中属性和input名冲突解决

form中属性跟input名冲突解决
<form action="http://www.163.com/" method="get">
<input type="text" name="action" value="http://www.sohu.com/" />
<button onclick="subm(this.form)">submit</button>
</form>
<script type="text/javascript">
function subm(o){
        o.attributes['action'].value = o.elements['action'].value;
        o.submit();
}
</script>

出现这种情况,很可能是因为 form 的 elements 里面有一个名为 action,
导致form.action出现冲突,因此在使用表单元素名称的时候,
尽量避免使用 submit reset action method name等作为elements的名称
一般情况下是不会出现问题,但是如果你需要用js去修改某个属性(如action method name等),
或者触发某个事件(如submit reset等)的时候,可能会出现这些冲突