Yes, the name 'action' should be avoided in the first place, even if that means changing other code extensively. Here's a better method than removing the node though:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function chng_a(el){
for (var i = 0, a=[], p=el.form.elements; i < p.length; i++)
if(p[i].name&&p[i].name.toLowerCase()=='action'){
a.push([p[i], p[i].name]);
p[i].removeAttribute('name', 0);
}
el.form.action='http://www.google.com';
for (var i = 0; i < a.length; i++)
a[i][0].setAttribute('name', a[i][1], 0);
}
</script>
</head>
<body>
<form action="#" name="regform">
<div><input type="hidden" name="action" value="createnew">
<input type="button" onclick="chng_a(this);" value="Change Action"><br>
<input type="submit" value="Go!"></div>
</form>
</body>
</html>
Bookmarks