weixin_33698823 2019-12-04 02:31 采纳率: 0%
浏览 67

HTML自定义按钮

I am having challenges to hide specific buttons when a record in MyDql Db is set to 'missed'. Please help, here is my code:

Database Connexion

$sql = "SELECT * FROM appointment";
$req = $bdd->prepare($sql);
$req->execute();
$events = $req->fetchAll(); 

HTML

Calendar API Downloaded from http://jamelbaz.com/tutos/integration-de-fullcalendar2-php-mysql

<div id="calendar" class="col-centered"> </div> 
<input type="text" name="title" class="form-control" id="title" placeholder="Name" >
<input type="text" name="surname" class="form-control" id="surname" placeholder="Surname">
<input type="submit" class="" id="Save" name="1" value="Save changes">
<input type="submit" id="try1" class="button alt" name="2" value="Arrived">
<input type="submit" id="try2" class="button alt" name="3" value="Did not arrived"> //once clicked hide Arrived button
<input type="submit" id="try3 class="button alt" name="3" value="Send email"> //show only if record is set to missed

Backend

eventRender: function(event, element) {
element.bind('click', function() {
$('#ModalEdit #name').val(event.name);
$('#ModalEdit #surname.val(event.surname);
},
events: [
<?php
foreach($events as $event): 
?>
title: '<?php echo $event['name'] ?>',
surname: '<?php echo $event['surname']; ?>',
<?php  endforeach;?>
]
});

enter image description here

  • 写回答

1条回答 默认 最新

  • weixin_33698043 2019-12-04 02:55
    关注

    Assuming your current ajax based approach is working, Use $('#your_button_id').prop("disabled", true); inside your foreach loop. Since this has many buttons, you need to have different button ids for each button to identify separately. you can use a row id or similar id with a name prefix for button ids.

    eventRender: function(event, element) {
    element.bind('click', function() {
    $('#ModalEdit #name').val(event.name);
    $('#ModalEdit #surname.val(event.surname);
    },
    events: [
    <?php
    foreach($events as $event): 
       if($event['status']=='missed') {
    ?>
          $('#your_button_id_or_class').prop("disabled", true);
    <?php
       }
    ?>
    title: '<?php echo $event['name']; ?>',
    surname: '<?php echo $event['surname']; ?>',
    <?php  endforeach;?>
    ]
    });
    
    评论

报告相同问题?