2017-04-14 52 views
1

我取出由数据库细节和同一页面显示,我必须更新重列的模糊值。我的问题是onblur无法正常工作。请查看下面的模糊功能代码,请帮助。 :)PHP如何让动态创建文本框的功能的onblur

<!DOCTYPE html> 
<html> 
<head> 
    <?php 
     include "dbconfig.php"; 
     include "yrsetup.php";  
     $ttable='lot'.$yr; 
    ?> 
    <style> 

    </style> 
<script type="text/javascript" src="jquery-1.6.1.js"></script> 
<script> 
    $(document).ready(function(){ 
     $("#tdate").change(function(){ 
     var tdate = $(this).val(); 
      $.post("lotno.php", 
        { 
         tdate: tdate 
        }, 
        function(data,status){ 
         $("#target-content").html(data); 
         //alert("Data: " + data + "\nStatus: " + status); 
      });   
     }); 

     $("#target-content").change(function(){ 
     var tlotno = $(this).val(); 
     var tdate = $("#tdate").val(); 
//alert(tlotno);   
     $.post("getdet.php", 
        { 
         tlotno: tlotno, 
         tdate: tdate 
        }, 
        function(data,status){ 
         $("#gtdet").html(data); 
         //alert("Data: " + data + "\nStatus: " + status); 
      });   
     }); 
/////////////////// 

//////////////////////////////// 
    $(".bweight").blur(function(){ 
    var text = $(this).val(); 
    alert(text); 
/* id = $(this).closest('.mob').attr('data-id'); 
      $.post("mobupdate.php", 
       { 
        id: id, 
        text: text 
       }, 
       function(data,status){ 
         // $("#target-content").html(data); 
         // alert("Data: " + data + "\nStatus: " + status); 
       });    
*/ 
}); 

}); 


</script> 

</head> 
    <body> 


enter code here 

    <form> 
      <table> 
       <tr> 
        <td> 
         Select Date:<input type="date" id='tdate' name='tdate' > 
        </td> 
        <td> 
         Select A/P/C: 
          <select name='apcslct' class='apcslct'> 
           <option>A</option>  
           <option>P</option>  
           <option>C</option>          
          </select> 
        </td> 

        <td> 
         Select LotNo: 
         <select id="target-content"></select> 
        </td> 
       </tr>    
      </table> 
      <div id="gtdet"> 

      </div> 
     </form> 

    </body> 
</html> 



getdet.php 

<?php 
    include "dbconfig.php"; 
    include "yrsetup.php";  
    $ttable='lot'.$yr; 

    $tdate1=$_POST['tdate']; 
    //$tdate1=date('d-m-Y'); 
    $tdate = date('Y-m-d', strtotime($tdate1)); 

    $tlotno=$_POST['tlotno']; 

    //echo $tdate; 
     $sql="SELECT lotno,asmsoc,$ttable.acno,CONCAT(assami.frst,' ',assami.send,' ',assami.thrd,' ',assami.vilg) AS ename, 
     $ttable.sacno,sno,apcd,allcodes.name AS iname,nobgs,kqty,kore,$ttable.rate,purno,pur.`send` as purnm,nqty AS weight 
     FROM $ttable 
     LEFT JOIN assami ON assami.mrk IS NULL AND $ttable.acno=assami.acno 
     LEFT JOIN allcodes ON allcodes.sw='IT' AND $ttable.`apcd`=allcodes.cd 
     LEFT JOIN pur ON pur.mrk IS NULL AND $ttable.purno=pur.`acno` 
     WHERE $ttable.mrk IS NULL AND date1='$tdate' AND atoz='$tlotno' AND asmsoc='A' UNION ALL 
     SELECT lotno,asmsoc,$ttable.acno,society.ename AS ename, 
     $ttable.sacno,sno,apcd,allcodes.name AS iname,nobgs,kqty,kore,$ttable.rate,purno,pur.`send` as purnm,nqty AS weight 
     FROM $ttable 
     LEFT JOIN society ON society.mrk IS NULL AND $ttable.acno=society.acno 
     LEFT JOIN allcodes ON allcodes.sw='IT' AND $ttable.`apcd`=allcodes.cd 
     LEFT JOIN pur ON pur.mrk IS NULL AND $ttable.purno=pur.`acno` 
     WHERE $ttable.mrk IS NULL AND date1='$tdate' AND atoz='$tlotno' AND asmsoc='S' ORDER BY lotno "; 

    $res=mysqli_query($mysqli,$sql); 
    if($res == FALSE) { 
     die(mysqli_error($mysqli)); // TODO: better error handling 
    }else{ 
     //printf("Select returned %d rows.\n", $res->num_rows); 
    } 
    $row=mysqli_fetch_array($res); 
?> 
<table border="1px"> 
<tr> 
    <th> 
     LOtno 
    </th> 
    <th> 
     A/S 
    </th> 
    <th> 
     Acno 
    </th> 

    <th> 
     Name 
    </th> 
    <th> 
     SubNo 
    </th> 
    <th> 
     Sno 
    </th> 
    <th> 
     Icode 
    </th> 
    <th> 
     Item 
    </th> 
    <th> 
     Bags 
    </th> 
    <th> 
     Kqty 
    </th> 
    <th> 
     Kore 
    </th> 
    <th> 
     Rate 
    </th> 
    <th> 
     PCode 
    </th> 
    <th> 
     PName 
    </th> 
    <th> 
     Weight 
    </th> 

</tr> 
<?php 
    do{ 
?> 
<tr> 
    <td> 
     <input type="text" disabled="disabled" name="lotno" class="lotno" value="<?php echo $row['lotno']; ?>" data-id="<?php echo $row['lotno'];?>" style="width:30PX" > 
    </td> 
    <td> 
     <?php echo $row['asmsoc'];?> 
    </td> 
    <td> 
     <?php echo $row['acno'];?> 
    </td> 
    <td> 
     <?php echo $row['ename'];?> 
    </td> 
    <td> 
     <?php echo $row['sacno'];?>  
    </td> 
    <td> 
     <?php echo $row['sno'];?> 
    </td> 
    <td> 
     <?php echo $row['apcd'];?> 
    </td> 
    <td> 
     <?php echo $row['iname'];?> 
    </td> 
    <td> 
     <?php echo $row['nobgs'];?> 
    </td> 
    <td> 
     <?php echo $row['kqty'];?> 
    </td> 
    <td> 
     <?php echo $row['kore'];?> 
    </td> 
    <td> 
     <?php echo $row['rate'];?> 
    </td> 
    <td> 
     <?php echo $row['purno'];?> 
    </td> 
    <td> 
     <?php echo $row['purnm'];?> 
    </td> 
     <?php if ($row['weight']>0){ ?> 
      <td> 
       <input type="number" class="bweight" value="<?php echo $row['weight'];?>" style="border:none;" onblur="blr(this);" > 
      </td> 
     <?php } else { ?> 
     <td > 
      <input type="number" class="bweight" style="border:none;" onblur="blr(this);"> 
     </td> 
     <?php } ?> 
    </td> 
    </td> 
</tr> 
<?php 
    }while ($row=mysqli_fetch_array($res)); 
?> 
</table> 
+0

你在控制台得到任何错误? –

回答

0

与升级的jQuery jQuery的即1.7+ jQuery On尝试内$(document).ready或者你可以使用live代替on

$("body").on("blur",".bweight",function(){ 
    var text = $(this).val(); 
    alert(text); 
}); 
+0

谢谢你,先生,现在它的工作。但不断警告消息显示其采取.bweight类适用于所有行如何解决这个问题。 –

+0

你好@NarayanBhat!你可以请你分享你的代码与jsFiddle。或者请用'blur'解释你想达到什么目的? –

+0

我想更新权重列到数据库。而不是发布其继续显示警报消息,因为相同的类被引用到所有表行。即时通讯新的堆栈溢出,所以我不知道如何链接jsFiddle代码。 –