Posted by bob on 01/18/08 11:52
radmission05@gmail.com ha scritto:
> On Jan 15, 11:04 am, Daniel Klein <dani...@featherbrain.net> wrote:
>> I'm pretty new at php and web stuff so please be gentle with me.
>>
>> I'm trying to get a form to submit when the user presses the Enter
>> key. I do not want to use javascript. I've googled this to death and
>> cant find the answer (only hints), except on the 'Experts Exhange'
>> page and you have to pay to get the answer :-(
>>
>> Why is this such a secret in the open source world we live in?
>>
>> Daniel Klein
>
> check this
>
> <script type="text/javascript">
> function submit_form(frm)
> {
> if(event.key==13)
> {
> document.getElementById(frm).submit();
> }
> }
>
> </script>
>
>
> <form name="myform" id="myform" action="">
> <input type="text" name="username" onkeydown="submit_form('myform')">
> <input type="password" name="password"
> onkeydown="submit_form('myform')">
> <input type="submit" name="Submit" value="Submit">
> </form>
This is HTML!
Whenever you type the ENTER key on a single <input> field you achieve a
SUBMIT as long as: a) the form has only that field; *or* b) the form has
an <input type="submit"> on it.
have fun!
[Back to original message]
|