2017-11-13 06:21



I am trying to send value to modal to query in table from database and display the value that come from WHERE clause that sent from variable I assign it to modal with 'id' attribute I try to save it with javascript in cookie but it show random value and not working correct

here is the link that i click on it to show modal it is in loop in table

    <a data-toggle="modal" href="#gurantorname" id="'.$payment_row["GuarantorID"].'"> Guarantor Discount</a>

and here is my modal :

<!-- gurarntour modal-->
<div id="gurantorname" class="modal fade" tabindex="-1" data-width="400">
    <div class="modal-header red">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
        <h4 class="modal-title"> اسم الكفيل  </h4>
    <div class="modal-body">
        if(isset($_COOKIE['myJavascriptVar'])) { 
            echo $_COOKIE['myJavascriptVar'];
            $guarantor_sth = $guarantorobj->getguarantorapplicationbyid($_COOKIE['myJavascriptVar']);
            $guarantor_row = $guarantor_sth->fetch();
        <label class=" font-blue-dark text-center">
                echo $guarantor_row["GuarantorFirstNameAR"].' '.$guarantor_row["GuarantorSecondNameAR"] .' '.$guarantor_row["GuarantorThirdNameAR"].' '.$guarantor_row["GuarantorLastNameAR"] ;
    <div class="modal-footer text-right">
        <a target="_blank"  class="btn green" href="index.php?action=guarantorinfo&guarantorid=<?php echo $payment_row["GuarantorID"];?>" >معلومات الكفيل</a>
        <button type="submit" data-dismiss="modal" class="btn btn-outline dark" >اخفاء</button>
<!--end of gurarntour modal-->

and here is my javascript that send cookie to modal :

<script type="text/javascript">
    $('#gurantorname').on('', function(e) {
        var $modal = $(this),
        esseyId =;
        document.cookie = "myJavascriptVar ="+esseyId ;
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dtd14883 dtd14883 4年前

    I think you should using ajax when user clicks on a link

    <a href="javascript:void(0)" class="link" id="'.$payment_row["GuarantorID"].'"> Guarantor Discount</a>

    and add the id attribute to label for showing guarantor_row by $payment_row["GuarantorID"]

    <label id="guarantor_row" class=" font-blue-dark text-center">

    let's create the ajax script

        var id = $(this).attr('id');
            method: "POST",
            url: "getguarantorapplicationbyid.php",
            data: { id:id  }
        .done(function( json_response) {
            var guarantor_row = $.parseJSON(json_response);             
            //set the data to modal and display
            $('#guarantor_row').text(guarantor_row.GuarantorFirstNameAR+" "+guarantor_row.GuarantorSecondNameAR);


    $guarantor_sth = $guarantorobj->getguarantorapplicationbyid($_POST['id']);
    $guarantor_row = $guarantor_sth->fetch();
    echo json_encode(guarantor_row);
    点赞 评论 复制链接分享