php - How can i display time in place of button? -


i want display time in place of button when button clicked button fadein , time show in place of button script not working button fadein , time didn't show in place of button , "time shown when refresh whole page not particular part refreshing."

foreach($leads $val):?> <tr><td class = 'account-name sort-value'> <span style='float:left;width:47%;'> <?php echo $val->first_name .' '. $val->last_name;?></span>&nbsp;&nbsp;&nbsp;&nbsp; <?php if($val->checkin_time != '') {?> <span class = 'dischktime' id = 'dischktime{<?php echo $val->lead_id;?>}' ><?php echo $val->checkin_time;?> </span> <?php  } else {?> <span style='float:left;width:26%;'> <button id ='checkin{<?php echo $val->lead_id;?>}' class='btn btn-default' name='checkinbt' value='<?php echo$val->lead_id; type='button'>checkin </button> </span> <?php } ?>&nbsp;&nbsp;&nbsp;&nbsp; <span> <?php echo $_session['drivername'];?> </span> </td></tr> <?php endforeach; } ?> <script type="text/javascript"> $(document).ready(function() { $("[id=checkin]").on("click" , function() { //$(this).fadeout(); $(this).fadeout('slow', function() { //alert("it's working"); $("‪#‎dischktime‬").show();-------(not working) }); $('button').submit(function(e) { e.preventdefault(); return false; }); //alert($(this).attr('value')); var lead_id = $(this).attr('value'); //alert(lead_id); $.ajax({ method: "post", url: 'search_db_test.php', data: 'checkinbt=' + lead_id, success: function(data) { $(this).html(data); //$("#dischktime").show(data);-----(not working) } }); }); }); </script> 

you creating element based on condition. when button shown time span having id : dischktime not created , not available in dom. modify foreach :

    foreach($leads $val):?>     <tr><td class = 'account-name sort-value'>     <span style='float:left;width:47%;'>     <?php echo $val->first_name .' '. $val->last_name;?></span>&nbsp;&nbsp;&nbsp;&nbsp;     <?php     if($val->checkin_time != '') {?>     <span class = 'dischktime' id = 'dischktime{<?php echo $val->lead_id;?>}' ><?php echo $val->checkin_time;?>     </span>     <?php      }     else {?>     <span style='float:left;width:26%;'>     <button id ='checkin{<?php echo $val->lead_id;?>}' class='btn btn-default' name='checkinbt' value='<?php echo$val->lead_id; type='button'>checkin     </button>     </span> **<span style="display:none;" class = 'dischktime ' id = 'dischktime{<?php echo $val->lead_id;?>}' >**     </span>     <?php }     ?>&nbsp;&nbsp;&nbsp;&nbsp;     <span>     <?php echo $_session['drivername'];?>     </span>     </td></tr>     <?php endforeach;     } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -