views:

160

answers:

3

Hi!

I want to make a form like this, and i want to post the form - with javascript - in all the keydowns.

<form action="{$formaction}" enctype="multipart/form-data" method="post">
<input type="text" name="n">
<input type="password" name="pw">
<button name="in" type="submit">enter</button>
</form>

please tell me how to do this.

A: 
<body onkeydown="document.forms["myform"].submit();">
Rody van Sambeek
Go with matt's solution, it's the cleanest. however i doubt the practical use.
Rody van Sambeek
+1  A: 
<form onkeydown="this.submit();">
  <!-- form content -->
</form>
Matt Huggins
A: 

If you do that, the page will reload, just as if you were clicking the submit button. What you probably want is to attach an onkeydown handler to the password field and submit key presses via AJAX.

For an example look at one of javascript auto-suggest libraries, e.g. AJAX Auto Suggest.

Yep, but i wanted to try it without ajax. :) Its just a login form and i want to save some cap from the server. Anyway its not workin as i want to so i have to do it with ajax :)
neduddki