user1925483
user1925483

Reputation: 5

how to process a form in html without using any button?

Can anyone please tell me how to insert data into database without page refresh and without using any button. Facebook wall posts area is an example. User writes whatever he wants in input field and he has to press ENTER to submit the data into database instead of using a submit button.

Upvotes: 0

Views: 73

Answers (2)

SBI
SBI

Reputation: 2322

If you're using jquery, you can do something along the lines of:

$(document).keydown(function(e) {
    if(e.which == 13) {
        your submit code
    }
}

Upvotes: 1

user1252065
user1252065

Reputation:

Browsers automatically submit a form if you hit enter within a <input type="text"> element.

Try

<form action="" onsubmit="alert(document.getElementById('t').value); return false;">
  <input type="text" id="t">
</form>

Upvotes: 0

Related Questions