Turbonis
Turbonis

Reputation: 15

Submit forms in HTML using textarea

is there any way i can submit a form without creating submit button, but using only type="text"? whenever i type every variable in the text area it submits.

I'm trying to create a live search using html and php mysql.

Upvotes: 0

Views: 69

Answers (2)

PeteAUK
PeteAUK

Reputation: 988

If you're doing a live search you're going to need to investigate AJAX (aka XHR). Submitting a form every time somebody changes the value of a textbox is a really bad way of doing it.

However if you really wanted to then you're going to have to attach an event listener to the textbox, listening for a keypress or keyup event.

What (if any) Framework are you using.

Upvotes: 0

Karthick Kumar
Karthick Kumar

Reputation: 2361

use onBlur event on textarea element and submit your form using java script like this

<form id="testform">
<textarea onblur="submitForm()"></textare>
</form>

<script>
function submitForm(){
document.getElementById("testform").submit();
}
</script>

Upvotes: 1

Related Questions