mercredi 11 août 2021

Make me this project in Laravel

I created this project in html, javascript, php. Now let me make it to Laravel. This is what happens when someone enters a value in the input box (code). After checking the code from the database, the name from the next column to this code will be valued in another input box (code name).

HTML code here:

 <input type="text" name="ccode[]" id="target" class="td-size" autocomplete="off" onchange="get(this.value);">
    <input type="text" name="cname[]" id="codename" class="td-size">

javascript code here:

<script type="text/javascript">
        function get(val){
            $.ajax({
              type: "POST",
              url: "ajaxData.php",
              data: 'ccode='+val,
              success: function(data) {
                $('#codename').css("font-weight","bold");
                $('#codename').attr('disabled', 'disabled');
                $('#codename').val(data);
                alert(data);
                }
            });  
        }
    </script>

php code here:

<?php

include('conn.php');

if(isset($_POST['ccode'])){
    $code = $_POST['ccode'];
    $brand="SELECT * FROM communitydata WHERE c_code = '".$code."' ";
    $data = mysqli_query($db,$brand) or die('error');
    while ($row = mysqli_fetch_assoc($data)) {
        $codename = $row['c_name'];
        echo "$codename";
    }
}
?>

database screenshot here:

enter image description here



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3s6nGp4
via IFTTT

Aucun commentaire:

Enregistrer un commentaire