PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_AJAX » Bug #8358

formSubmit gives error in IE fields named 'action'

Details

Submitted2006-08-04 10:40 UTC
Fromgapfontaine at gmail dot com
Assignedarpad
StatusClosed
PackageHTML_AJAX
PHP Version4.4.1
OS*
Roadmaps(Not assigned)

Comments

[2006-08-04 10:40 UTC] gapfontaine at gmail dot com

Description:
------------
In IE (my version: 6.0.2800), formSubmit(this, 'target') gives an error if one of the input fields is named 'action'. I guess because of <form action='script.php ...> ?
Firefox doesn't have this issue.
See example code. The example uses a submit button named 'action' but the same thing happens if it's a hidden or text input field.
Using another name instead of 'action' such as 'act' or 'task' solves the problem. This is a pain because all of my scripts use $action to determine what to do :)

Test script:
---------------
<?php
if( $_REQUEST["action"]=="go" ) {
var_dump( $_REQUEST );
exit(0);
}
?><html>
<head>
<script type="text/javascript" src="server.php?client=all&stub=all" language="JavaScript"></script>
</head>
</body>
<pre id="target">
</pre>
<form action="rpcTest.php" method="post" onSubmit="return !HTML_AJAX.formSubmit(this, 'target');">
<input type="text" name="text" value="some text">
<input type="submit" name="action" value="go">
</form>
</body>
</html>

Expected result:
----------------
The name of the form input fields should not affect functionality.

Actual result:
--------------
Error from IE:

Line: 1722
Char: 9
Error: HTTP Error Making Request: [404] Not found
Code: 0
URL: (my script url, which is there!)

[2006-08-04 12:22 UTC] gapfontaine at gmail dot com

I saw a previous post where
var action = form.action;
is changed to
var action = for.getAttribute('action');
This works with FF but still gives an error in IE.

[2006-08-04 15:33 UTC] gapfontaine at gmail dot com

After some trial and error with FF and IE, it seems that this works:
var action = form.attributes['action'].value;
instead of
var action = form.getAttributes('action');