Reputation: 397
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">
Upvotes: 2
Views: 146
Reputation: 306
Use javascript to send the form
<html>
<head>
<script type="text/javascript">
function myFunction() {
document.getElementById("myForm").submit();
}
</script>
<body>
Hello World!
<form action="find.php" id="myForm">
<input type = "text" id = "textfield" onblur="myfunction()">
</form>
</body>
</html>
Upvotes: 0
Reputation: 8349
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>
Upvotes: 3
Reputation: 6572
In your actual code, $_POST['textfield']
will always be unset.
Use,
<input type="text" id="whatever" name="textfield">
isset($_POST['submit'])
is just a convention, just to check that the POST data is coming from form - not anywhere else.
So, ofcourse you can, but be aware of securrity problems.
Upvotes: 0