unknown unknown - 4 months ago 8
HTML Question

Use textfield instead of submit button to pass data

Hi guys I just want to know if there is another way to pass form from php using textfield instead of submit button, because i want to send my updated data using textfield or password so the user will just enter the textfield after typing this is how my code looks like

if(isset($_POST['textfield']))
{
echo "send data";
}

<input type = "text" id = "textfield">

Answer

Execute a javascript function on textfield's onblur event and submit your form on its blur event.

<form id="form">
<input type = "text" id = "textfield" onblur="submitMe()">
</form>

<script>
function submitMe() {
$("#form").submit();
}
</script>