View Full Version : Submit Form
Hello everyone. Here is the thing, I have a HTML Form that has only one field that has to be entered by the user, and the submit button. What I´m trying to do is to be able to submit the form by hitting enter on the keyboard, after a value is entered on the field, in other words without pressing the submit button with the mouse. Anyone knows how to do it? Thanks for any help.
agent002
05-28-2004, 02:06 PM
Well, if it's a valid form, that should happen automatically... can you show us the code please, or give a link if you have it online?
It is not on the web, it is actually a aplication running in a intranet. The whole application is in Java only the interface uses HTML, and I think that could be the problem.
Here is the code;
<form jwcid="emitirContratoFrmEmitir">
<table width="100%">
<tr>
<td class="itens">Descrição: </td>
</tr>
<span jwcid="emitirContratoForeachDescricao">
<tr>
<td align="left"> <input jwcid="emitirContratoInsDescricao"/></td>
<td width="40%"></td>
<td align="right"><input jwcid="emitirContratoBtnEmitir" type="submit" class="botao" value="Emitir Contrato"/></td>
</tr>
</span>
</table>
</form>
afterburn
05-28-2004, 02:40 PM
document.onkeydown = func
function func()
{
if(event.keyCode==13)
{
document.forms[0].submit();
}
}
works in IE the syntax is e.which for NS but the point is the same. Just check for browser
agent002
05-28-2004, 02:42 PM
Well, I would rather fix the code, Afterburn... I mean, you can't wrap a table row (<tr></tr>) in a span. That's probably what causes the browser not to submit the form on enter.
afterburn
05-28-2004, 02:53 PM
Ohh I didn't read your post... LOL
Thanks a lot "afterburn" your code did exactly what I needed.
vBulletin® v3.6.7, Copyright ©2000-2010, Jelsoft Enterprises Ltd.