views:

58

answers:

2

I have a form like this:

<form id="form_main" name="form_main" action="/search/" target="iframe001" method="get" onSubmit="reset_and_subm();">

Enter key wont submit this form in IE6, but will in Chrome, FF, Opera, Safari, and IE8 (haven't tested IE7 yet). IN FACT, NOT EVEN PRESSING THE SUBMIT BUTTON SUBMITS THE FORM. I have tried for hours now... What could be the problem? I have tried this:

<form id="form_main" name="form_main" action="/search/" target="iframe001" method="get" onSubmit="alert('hello');">

And the alertbox comes up with the message...

Now here is the function "reset_and_subm();"

function reset_and_subm(){
    document.getElementById("p").value = 1;
    return true;
}

Does anybody know what I should do here?

Btw, I have checked all inputs in the form, and all seem okay... So assume there is nothing wrong with the content of the form.

Thanks

UPDATE:

I have a submit button yes. The entire form content is way to large to put here, but it contains only one textfield. The rest is "selects" and "hidden inputs". I am pressing enter in the only textfield there is... Also I have added the code of the submit button:

<input name="nav_querystring" type="text" id="nav_querystring" style="width: 240px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold;" value="">

<input type="submit" name="nav_submit" id="nav_submit" value="Sök" style="width: 55px; font-size: 13px;">

UPDATE2:

Just to point out, I have included the js file which contains the function "reset_and_subm" and also, I am using mod_rewrite in .htaccess to rewrite the action of the form. I hope none of this is causing the issue.

UPDATE3: Seems the problem might lie in the body OnLoad eventy, where I have a js function not listed here. Doesn't IE6 support OnLoad? What should I use instead...

Here is my current code:

  <body onLoad="subSelection();">

Thanks

A: 

I seem to remember there is a strange bug with only one text box on a page in IE6 that we had to work around a long time ago. Try putting another empty textbox on the page with its style set to display: none and see if that works. It might sound crazy but that's what happens with crazy IE bugs...

Chris
Tried it, but didn't solve the problem... Thanks anyways Chris.
Camran
@Camran: http://stackoverflow.com/questions/270494/enter-button-does-not-submit-form-ie-only-asp-net/487965#487965 seems to be what I was struggling for. Maybe you need to have it in a hidden div rather than being hidden itself. There are other options on that page that might help too.
Chris
Chris, thanks alot for your help... Check my third update, might be the problem here... I will meanwhile look into the question you linked to.
Camran
+1  A: 

I have made two changes to your code.

As you are calling a function from onsubmit, I have included the "return" keyword in the method call.

As the form only has one form element, I have added a hidden element to the form.

<form id="form_main" name="form_main" action="/search/" target="iframe001" method="get" onSubmit="return reset_and_subm();">
    <div style="display: none;"><input type="text" name="ie6"></div>
    <input name="nav_querystring" type="text" id="nav_querystring" style="width: 240px; font-family:Arial, Helvetica, sans-serif; font-size:12px; font-weight:bold;" value="">
    <input type="submit" name="nav_submit" id="nav_submit" value="Sök" style="width: 55px; font-size: 13px;">
</form>

Please shout if you are still stuck.

Sohnee
Thanks, but still no luck... This is one of those creepy errors which will take a loooong time to find. Is there any good IE6 debugging tool anywhere?
Camran
Do a search for IE Developer Tools, it is a bit like Firebug for Firefox.
Sohnee