www.webdeveloper.com
Results 1 to 4 of 4

Thread: Multiple Ajax Live Search

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Posts
    39

    Multiple Ajax Live Search

    Sir,
    I am using these codes.

    PHP Code:
    <script type="text/javascript">
    $(
    "#moba").change(function() {
    var 
    formVal = $("#moba").val();
    $.
    get"ajax_find.php", { idformVal } ) .done(function( data 
    {
         $(
    '#my_name').val(data);
          $(
    '#mobb').val(data);
         $(
    '#email').val(data);
    });
    });
    </script> 
    And ajax_find.php has these codes

    PHP Code:
    <?php
        
    require_once("connect.php");
        if (isset(
    $_GET['id']))
        {
            
    $sno =trim($_GET['id']); 
            
    $record_check ="SELECT * FROM contacts WHERE moba = '$sno' ";
            
    $result=mysqli_query($con$record_check);
            
    $row mysqli_fetch_array($result); 
            echo (!
    $row) ? "" $row['name'];
            echo (!
    $row) ? "" $row['mobb'];
            echo (!
    $row) ? "" $row['email'];
        }
    ?>
    It shows data as
    My_name=Eric00924587582abc@hotmail.com
    (3 fields data in FIRST textbox only)


    But I want to display data in 3 textbox which has idís as

    $('#my_name').val(data);
    $('#mobb').val(data);
    $('#email').val(data);


    It must display data as

    my_name=Eric
    mob=00924587582
    email= abc@hotmail.com

    How to modify both files?

  2. #2
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    5
    Hi, in php code try this:
    PHP Code:
     <?php
        
    require_once("connect.php");
        if (isset(
    $_GET['id']))
        {
            
    $sno =trim($_GET['id']); 
            
    $record_check ="SELECT * FROM contacts WHERE moba = '$sno' ";
            
    $result=mysqli_query($con$record_check);
    if(
    mysql_num_rows($result)>0)
    {

     
    $row mysqli_fetch_array($result); 
    $res=$row['name']."##".$row['mobb']."##".$row['email'];
    echo 
    $res;
    }



           

            
        }
    ?>
    into file ajax:
    PHP Code:
    <script type="text/javascript">
    $(
    "#moba").change(function() {
    var 
    formVal = $("#moba").val();
    $.
    get"ajax_find.php", { idformVal } ) .done(function( data 
    {
    res_value=data.split("##");
         $(
    '#my_name').val(res_value[0]);
          $(
    '#mobb').val(data[1]);
         $(
    '#email').val(data[2]);
    });
    });
    </script> 
    other solution to read values ​​with json

  3. #3
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    5
    I can not find the button "edit" I made a small error:correctly is:
    [php]
    $('#my_name').val(res_value[0]);
    $('#mobb').val(res_value[1]);
    $('#email').val(res_value[2]);
    [/]

  4. #4
    Join Date
    Dec 2011
    Posts
    39
    Thanks Sir, I work fine now

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles