dth20986 2016-04-20 10:14
浏览 53

更改datepicker后连续更新日期字段

I have a table that contains a column of dates that can be changed through the datepicker .

<td>
   <div class="input-group date" data-provide="datepicker">
        <input type="text" class="form-control" name="dataPrevisao" id="dataPrevisao" rel="<?php echo odbc_result($resultado,"stamp");?>" value="<?php echo odbc_result($resultado,"dvalor");?>" />
        <div class="input-group-addon">
             <span class="glyphicon glyphicon-calendar small"></span>
        </div>
   </div>

What i want to do, is after the change of date, the register is automatically updated in the table. For that, i have a php file - changePrevisao.php:

<?php include("includes/odbc.ini"); 
$iniciais=str_replace(' ', '', $_SESSION['iniciais']);
$stamp=$_POST['stamp']; 
$dataP=$_POST['dataP']; 
$query = "  update od set marcada=1, data='$dataP', usrdata=convert(varchar(10),getdate(),112),
            usrhora=right(convert(varchar(19),getdate(),121),8), usrinis='$iniciais' where od.odstamp='$stamp'";
odbc_exec($sqlconnect,$query); 
?>

I have problems in building the user function to ajax that allows pass the data to the php file , does anyone can help me ?

  • 写回答

1条回答 默认 最新

  • dongpao2871 2016-04-21 11:38
    关注

    After searching and testing , I created the following function:

    <script>
        $(document).ready(function(){
        $(document).on('change', '#dataPrevisao', function () {
            var stamp = $(this).attr('rel');
            var dataP = $(this).val();
            var dataString = 'stamp='+ stamp +'&dataP='+ dataP;
            $.ajax({
                type: "POST",
                url: "changePrevisao.php",
                data: dataString,
                cache: false,
                success: function(new_data){
                        $(stamp).html(new_data);
                        $(stamp).dialog();
                        alert('Load was performed.');
        }
       });
      });
    });
    </script>
    

    Now i can update the date in the db, but the result is not as i expected, the change only occurs when I change directely the input and not through the datepicker. What do I need to change in the function so that it takes into account the changes made by the datepicker ?

    评论

报告相同问题?

悬赏问题

  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗