locked
how to apply a DOM value in JQuery plugins? RRS feed

  • Question

  • User-1827895486 posted

    I created an Ajax code which could change the value in the span but what I actually want is the value apply into the Jquery seat-charts plugin, is there any way to move the output of Ajax to Jquery plugins?

    Wednesday, August 29, 2018 11:46 PM

Answers

  • User839733648 posted

    Hi  huyteoh,

    According to your description and codes, I suggest you could refer to: https://github.com/mateuszmarkowski/jQuery-Seat-Charts

    You should firstly notice the definition of map. You could literally pass an array of strings which represents succeeding rows.

    You’ve said that you’ve got the required values successfully through Ajax. And then the key point is how to add the values to the plugin.

    I suggest that you could pay attention to the method .status( ids, status).

    This may update status for a seat set with given ids. ids variable may contain a single id or a an array of ids.

    sc.status('2_15', 'unvailable'); //set status for one seat
    sc.status(['2_15', '2_10'], 'unvailable'); //set status for two seats
    

    By using the method, you may set your values’ status as you want.

    The method get(ids) is used to return set of seats. This cannot modify the status. You can pass either one id or an array of ids.

    sc.get('2_3'); //get 2_3 seat
    sc.get(['2_3', '2_4']); //get 2_3 and 2_4 seats
    

    The last thing I want to say is that, I’m sorry that I could not make a sample to help with you.

    Because this is a forums about ASP.NET and I’m not skilled at PHP. But I hope that my ideas above may be helpful to you.

    Best Regards,

    Jenifer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 31, 2018 10:04 AM

All replies

  • User-1827895486 posted

    below is my plugin code:

    <script> $(document).ready(function(){ $("#time-select").change(function(){ var time = $("#time-select").val(); var date = $("#date").val(); var branch = $("#branchval").val(); $.ajax({ url: "Bookingajax.php", type: "post", async: false, data: { "done": 1, "time": time, "date": date, "branch": branch }, success: function(data){ $("#checkspan").html(data); } }); }); }); </script>

    and this is my Ajax code in Bookingajax.php

     <?php

    include "include/conn.php"


     if(isset($_POST['done'])){
       $time = $_POST['time'];
       $date = $_POST['date']; 
       
       if($_POST['branch'] == 'Penang Bukit Tengah'){
        $branch = "1101";
       } else if($_POST['branch'] == 'Kuala Lumpur Bukit Jalil'){
        $branch = "1102";
       } else if($_POST['branch'] == 'Kuala Lumpur Bukit Bintang'){
        $branch = "1103";
       }
     $sql = "SELECT * FROM reservation WHERE rsv_time = '".$time."' AND rsv_date = '".$date."' AND branch_ID = '".$branch."'";    
     $result = mysqli_query($conn, $sql);
     
     while($row = mysqli_fetch_array($result)) {
      echo $row['tbl_ID'];
     }

    ?>

    and when time change the Ajax will show the output in this span

    <span id="checkspan"></span>

    and what I want is the value be fetch into the sc.get, the span is just the testing for me to see whether the Ajax is work or not, my main purpose is to change the seats in sc.get. is there any solution for this? sc.get(['01_A','01_D']).status('unavailable');

    Wednesday, August 29, 2018 11:47 PM
  • User839733648 posted

    Hi  huyteoh,

    According to your description and codes, I suggest you could refer to: https://github.com/mateuszmarkowski/jQuery-Seat-Charts

    You should firstly notice the definition of map. You could literally pass an array of strings which represents succeeding rows.

    You’ve said that you’ve got the required values successfully through Ajax. And then the key point is how to add the values to the plugin.

    I suggest that you could pay attention to the method .status( ids, status).

    This may update status for a seat set with given ids. ids variable may contain a single id or a an array of ids.

    sc.status('2_15', 'unvailable'); //set status for one seat
    sc.status(['2_15', '2_10'], 'unvailable'); //set status for two seats
    

    By using the method, you may set your values’ status as you want.

    The method get(ids) is used to return set of seats. This cannot modify the status. You can pass either one id or an array of ids.

    sc.get('2_3'); //get 2_3 seat
    sc.get(['2_3', '2_4']); //get 2_3 and 2_4 seats
    

    The last thing I want to say is that, I’m sorry that I could not make a sample to help with you.

    Because this is a forums about ASP.NET and I’m not skilled at PHP. But I hope that my ideas above may be helpful to you.

    Best Regards,

    Jenifer

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 31, 2018 10:04 AM