Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to get textbox value in php without submit

In jQuery, for brevity:

// or $('#textbox_autopost').blur if you want to do it when the box loses focus
$('#textbox_autopost').change(function(){
    $.ajax({
        type: "POST",
        url: "some.php",
       data: {text:$(this).val()}
    });
});

if you want to do it via button click

<button id="inlinesubmit_button" type="button">submit</submit>

$('#inlinesubmit_button').click(function(){
    $.ajax({
        type: "POST",
        url: "some.php",
       data: {text:$('#textbox').val()}
    });
});

You can also do it through an A HREF (or submit button, or or something else wacky:

<!-- backup if JS not available -->
<a href="handler.php" id="inline_submit_a">add comment</a>

$('#inline_submit_a').click(function(evt){
    $.ajax({
        type: "POST",
        url: "some.php",
       data: {text:$('#textbox').val()}
    });
    evt.preventDefault();
    return false;
});
If you want to do it on enter:

$('#textbox_autopost_onenter').keydown(function(evt){
    if ((evt.keyCode) && (evt.keyCode == 13))
    {
      $.ajax({
        type: "POST",
        url: "some.php",
        data: {text:$(this).val()}
      });
      evt.preventDefault();
      return false;
    }
});

Final, site-ready code:

$(document).ready(function(){
   function submitMe(selector)
   {
        $.ajax({
          type: "POST",
          url: "some.php",
          data: {text:$(selector).val()}
        });

   }
   $('#textbox_button').click(function(){
      submitMe('#textbox');
   });
   $('#textbox').keydown(function(evt){
      if ((evt.keyCode) &&(evt.keyCode == 13))
      {
         submitMe('#textbox');
         evt.preventDefault();
         return false;
      }
   });
Comment

PREVIOUS NEXT
Code Example
Php :: Uncaught TypeError: call_user_func(): Argument #1 
Php :: exists:categories,id except a value laravel 
Php :: laravel how to generate short link in laravel framework and relation with 3 model 
Php :: js data php 
Php :: Unregistering a variable with $_SESSION. 
Php :: paygate logout session on callback laravel 
Php :: comment php laravel template blade 
Php :: cout post on category in controller laravel 
Php :: laravel after method() 
Php :: base64 to arraybuffer php 
Php :: laravel livewire public property 
Php :: php curl fail verbosly 
Php :: phpmailer 5 string attachment 
Php :: buddy group hide notice join 
Php :: php Least prime factor of numbers till n 
Php :: php notice: trying to access array offset on value of type bool in /usr/share/php/pear/rest.php on line 187 
Php :: Detecting specifically the My account "Dashboard" page 
Php :: WP Admin Bar Dev Links 
Php :: remove all breadcrumbs php 
Php :: return multiple rows from mysqli php and encode JSON 
Php :: woocommerce php customer reset password length 
Php :: laravel openstreetmap 
Php :: sync fetch eloquent laravel 
Php :: php shell_exec must be connected to a terminal 
Php :: zsh: command not found: php mac 
Php :: cmd download file from url 
Php :: try/catch -- much needed 
Php :: laravel download file from storage with progress bar 
Php :: mamp change php version 
Php :: php array dot notation 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =