I am having problems with this form it has two submit options a button and an onchange instance the onchange just will not work can any one tell me why?

my doc type is

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

the form is

<table class="mailbox">
<form id="form1" action="mymessages.php?" method="post">
<tr><td colspan="4" class="header"><?=$folder?></td></tr>
<tr><td colspan="2" class="header">Subject</td><td class="header">Date</td><td class="header">From</td></tr>
if ($messagecount>0)
echo'<tr><td class='.$viewclass.'><input type="checkbox" name="selected" value="'.$mid.'" /><td class='.$viewclass.'><a href="mymessages.php?&mid='.$mid.'">'.$subject.'</a></td><td class='.$viewclass.'>'.$daterec.'</td><td class='.$viewclass.'>'.$fromuser.'</td></tr>';
if ($messagecount<0)
echo '<tr><td colspan="4">You have no messages in your '.$folder.'</td></tr>';
<tr><td class="header"><input type="submit" name="submit" value="Delete" /></td><td colspan="3" class="header">Move To:
<select name="test" onchange="submit()">
<option value="" selected="selected">Folder</option>
$folders   = ucwords($row["folder"]);
if ($folders==$folder)
$folders == " ";
echo '<option value="'.$folders.'">'.$folders.'</option>';
7 Years
Discussion Span
Last Post by shadiadiph


I've seen this before and it's a weird one! An language/browser bug in my opinion.

In your submit button's tag, name="submit" kind of hijacks submit() , or even this.form.submit() within the form, so you get a javascript error.

Solution: Change name="submit" to eg. name="formSubmit" .

If you read $_POST server-side, remember to modify your php accordingly.



awesome thank you this has been puzzling me as my scripting seems fine i guess it must be a browser issue. thanks


the onchange submit now works but i just tested it like this i changed the name="submit" to name="formSubmit" like you said and just did a test in the heading to get a response from posting using.

if (isset($_POST["submit"]))
print "hello";
if (isset($_POST["formSubmit"]))
print "goodbye";

clciking on the delet value button produces goodbye fine but the onchange submit returns nothing?? sorry i am useless at javascript so i have no idea what it is asking me for.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.