  | 
              
	              
	                
  
    
	 
        การส่งค่าของ Check Box ในรูปแบบของ Array เพื่อแก้ไขจำนวนอ่ะค่ะ     | 
   
  
    |   | 
   
 
 
 
              
  
          
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 มีรายการหนังสือที่ในนั้นมีหลายๆรายการ  <=== ฟังแล้วงงครับ 
 
ลองจับภาพหน้าจอมาให้ดู และโค้ดที่มีการวนลูปดึงข้อมูลเพื่อสร้าง checkbox ด้วยครับ                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-12 23:02:01 | 
                        By :
                            sakuraei | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                   
 
นี่ค่ะ รูปภาพ ช่วยดูให้หนูหน่อยน๊า ไม่ไหวจะเคลียแล้ว!!!!! 
 
Code (PHP) 
<script language="javascript">            
///////////////////////////////////// คำนวณเงินรวมจาก checkbox ที่เลือก //////////////////////////////////////
function selectChange(no){
	//alert(no);
var sum = 0;
var qty    = new Array();
var price  = new Array();
var stotal = new Array();
var titles =  frmbuy.elements['buy[]'];
 for(var a=no;a<=no;a++){
	//alert(no);
	//alert(a);
	//alert(titles[a].value);
	 if (titles[a].checked==true) {	 
	 //alert("open");
		   price[a] = document.getElementById('txtprice'+a).disabled=false;
	         qty[a] = document.getElementById('txtqty'+a).disabled=false;
		  stotal[a] = parseFloat(document.getElementById('txtstotal'+a).value);
			sum+= stotal[a];
		}else if (titles[a].checked==false) {
			//alert("close");
			price[a] = document.getElementById('txtprice'+a).disabled=true;
	         qty[a] = document.getElementById('txtqty'+a).disabled=true;
				
	}
}
}
</script>              
<script language="javascript">
function checkNum()
{	
	var qty    = new Array();
	var   q    = new Array();
	var   t    = new Array();
	var  st    = new Array();	
	var price  = new Array();
	
	
		
	for(var i=0;i>=<?=$No;?>;i++){
		price[i] = document.getElementById('txtprice'+i).value;
	      qty[i] = document.getElementById('txtqty'+i).value;
		    q[i] = document.getElementById('q'+i).value;
			t[i] = document.getElementById('t'+i).value;
		   st[i] = document.getElementById('st'+i).value;
			   
		  
	var    total = price[i]*qty[i];
		document.getElementById('txtstotal'+i).value = total; 	
		if(total==0){	
			document.getElementById('txttotal'+i).value = ("0.00");
	
		}else{
			document.getElementById('txttotal'+i).value = total.toLocaleString();
		}
		
		if(document.getElementById('txtqty'+i).value.match(/^0/)){
			document.getElementById('txtqty'+i).value=q[i];;	    
				 document.getElementById('txttotal'+i).value=t[i];
					alert('จำนวนสินค้าที่ส่งคืน ต้องมีจำนวนมากกว่า 0');				
				 document.getElementById('txtqty'+i).value=q[i];
				 document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
	    	   document.getElementById('txtqty'+i).value.focus();
			return false;
		
		}
		if(!document.getElementById('txtqty'+i).value.match(/^([0-9]+)$/)) {
	 		   document.getElementById('txtqty'+i).value=q[i];
			    document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
			     alert('กรุณากรอก จำนวนสินค้าที่ส่งคืน ด้วยตัวเลขเท่านั้น');	
				 document.getElementById('txtqty'+i).value=q[i];
				 document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
	    	   document.getElementById('txtqty'+i).value.focus();
			return false ;
		}
  		if(parseInt(document.getElementById('txtqty'+i).value) > parseInt(document.getElementById('q'+i).value)){
				 document.getElementById('txtqty'+i).value=qty[i];
				 document.getElementById('txttotal'+i).value=total.toLocaleString();
			   document.getElementById('txtstotal'+i).value=st[i];
				 alert('คุณไม่สามารถกรอกจำนวนสินค้าที่ส่งคืน มากกว่า จำนวนสินค้าที่รับ');
				  document.getElementById('txtqty'+i).value=q[i];
				   document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
	    	   document.getElementById('txtqty'+i).value.focus();
			return false ;	
		}
    
	}
	
	}       
</SCRIPT>    
<?			while ($record=mysql_fetch_array($result_data)){
			$id_de = $record['redetail_id'];
			$id_or = $record['re_id'];
			$id_pro = $record['p_code'];
			$price_pro = $record['p_pricere'];
			$qty_or = $record['p_reqty'];	
			
		$sqlpro= "select * from tbl_product where p_code = '$id_pro' ";
 			$data=mysql_query($sqlpro);			
			while ($result=mysql_fetch_array($data)){
?>
     <tr height="30" bgcolor="#FFFFCC">
     <td align="center" width="45"><input type="checkbox" name="buy[]" id="buy[]" value="<?=$result["p_code"];?>" onClick="selectChange('<?=$No;?>');"></td>
     <td align="center"><?=$num;?> <div id="NO">NO = <?=$No;?></div></td>
     <td align="center"><?=$result["p_code"];?>
     <input type="hidden" name="pcode[]" id="pcode<?=$No;?>" value="<?=$result["p_code"];?>">
     <input type="hidden" name="txtreceive[]" id="txtreceive<?=$No;?>" value="<?=$receiveorder;?>"></td> 
	 <td>  <?=$result["p_name"];?></td>
     <td align="right"><?="".number_format($result["p_pricebuy"], 2,'.',',');?>  
	<input type="hidden" name="txtprice[]" id="txtprice<?=$No;?>" style="width:55px;text-align:right" value="<?="".number_format($result["p_pricebuy"], 2,'.',',');?>" disabled>
     </td>
     <td align="center">
<input type="text" name="txtqty[]" id="txtqty<?=$No;?>" style="width:30px;text-align:center" value="<?=$record["p_reqty"];?>" onKeyUp="checkNum()" disabled />
<input type="hidden" name="q" id="q<?=$No;?>" style="width:30px;text-align:center"  value="<?=$record["p_reqty"];?>"></td>
    
    <td align="right"><input type="text" name="txttotal" id="txttotal<?=$No;?>" style="width:65px;text-align:right"  value="<?="".number_format($record["p_pricere"], 2,'.',',');?>" disabled> 
<input type="hidden" name="txtstotal[]" id="txtstotal<?=$No;?>" value="<?=$record["p_pricere"];?>" style="width:65px;text-align:right"  />    
<input type="hidden" name="t" id="t<?=$No;?>" style="width:30px;text-align:center" value="<?="".number_format($record["p_pricere"], 2,'.',',');?>">
<input type="hidden" name="st" id="st<?=$No;?>" style="width:30px;text-align:center" value="<?=$record["p_pricere"];?>">
</td>
	</tr>
<?                         
$num++;                                 
$No++;			
								  
								  $strTotal=$strTotal+$record["p_pricebuy"];
								  $disTotal=($strTotal*$_SESSION["discount(%)"])/100;
								  $numTotal=$numTotal+$record['p_qtybuy'];
								  $priceTotal=$strTotal-$disTotal;
								  
}}
?>
        </table>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 04:46:43 | 
                        By :
                            Help Me | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 นี้ Code อ่ะค่ะ 
 
Code (PHP) 
<script language="javascript">            
///////////////////////////////////// คำนวณเงินรวมจาก checkbox ที่เลือก //////////////////////////////////////
function selectChange(no){
	//alert(no);
var sum = 0;
var qty    = new Array();
var price  = new Array();
var stotal = new Array();
var titles =  frmbuy.elements['buy[]'];
 for(var a=no;a<=no;a++){
	//alert(no);
	//alert(a);
	//alert(titles[a].value);
	 if (titles[a].checked==true) {	 
	 //alert("open");
		   price[a] = document.getElementById('txtprice'+a).disabled=false;
	         qty[a] = document.getElementById('txtqty'+a).disabled=false;
		  stotal[a] = parseFloat(document.getElementById('txtstotal'+a).value);
			sum+= stotal[a];
		}else if (titles[a].checked==false) {
			//alert("close");
			price[a] = document.getElementById('txtprice'+a).disabled=true;
	         qty[a] = document.getElementById('txtqty'+a).disabled=true;
				
	}
}
}
</script>              
<script language="javascript">
function checkNum()
{	
	var qty    = new Array();
	var   q    = new Array();
	var   t    = new Array();
	var  st    = new Array();	
	var price  = new Array();
	
	
		
	for(var i=0;i>=<?=$No;?>;i++){
		price[i] = document.getElementById('txtprice'+i).value;
	      qty[i] = document.getElementById('txtqty'+i).value;
		    q[i] = document.getElementById('q'+i).value;
			t[i] = document.getElementById('t'+i).value;
		   st[i] = document.getElementById('st'+i).value;
			   
		  
	var    total = price[i]*qty[i];
		document.getElementById('txtstotal'+i).value = total; 	
		if(total==0){	
			document.getElementById('txttotal'+i).value = ("0.00");
	
		}else{
			document.getElementById('txttotal'+i).value = total.toLocaleString();
		}
		
		if(document.getElementById('txtqty'+i).value.match(/^0/)){
			document.getElementById('txtqty'+i).value=q[i];;	    
				 document.getElementById('txttotal'+i).value=t[i];
					alert('จำนวนสินค้าที่ส่งคืน ต้องมีจำนวนมากกว่า 0');				
				 document.getElementById('txtqty'+i).value=q[i];
				 document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
	    	   document.getElementById('txtqty'+i).value.focus();
			return false;
		
		}
		if(!document.getElementById('txtqty'+i).value.match(/^([0-9]+)$/)) {
	 		   document.getElementById('txtqty'+i).value=q[i];
			    document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
			     alert('กรุณากรอก จำนวนสินค้าที่ส่งคืน ด้วยตัวเลขเท่านั้น');	
				 document.getElementById('txtqty'+i).value=q[i];
				 document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
	    	   document.getElementById('txtqty'+i).value.focus();
			return false ;
		}
  		if(parseInt(document.getElementById('txtqty'+i).value) > parseInt(document.getElementById('q'+i).value)){
				 document.getElementById('txtqty'+i).value=qty[i];
				 document.getElementById('txttotal'+i).value=total.toLocaleString();
			   document.getElementById('txtstotal'+i).value=st[i];
				 alert('คุณไม่สามารถกรอกจำนวนสินค้าที่ส่งคืน มากกว่า จำนวนสินค้าที่รับ');
				  document.getElementById('txtqty'+i).value=q[i];
				   document.getElementById('txttotal'+i).value=t[i];
			   document.getElementById('txtstotal'+i).value=st[i];
	    	   document.getElementById('txtqty'+i).value.focus();
			return false ;	
		}
    
	}
	
	}       
</SCRIPT>    
<?			while ($record=mysql_fetch_array($result_data)){
			$id_de = $record['redetail_id'];
			$id_or = $record['re_id'];
			$id_pro = $record['p_code'];
			$price_pro = $record['p_pricere'];
			$qty_or = $record['p_reqty'];	
			
		$sqlpro= "select * from tbl_product where p_code = '$id_pro' ";
 			$data=mysql_query($sqlpro);			
			while ($result=mysql_fetch_array($data)){
?>
     <tr height="30" bgcolor="#FFFFCC">
     <td align="center" width="45"><input type="checkbox" name="buy[]" id="buy[]" value="<?=$result["p_code"];?>" onClick="selectChange('<?=$No;?>');"></td>
     <td align="center"><?=$num;?> <div id="NO">NO = <?=$No;?></div></td>
     <td align="center"><?=$result["p_code"];?>
     <input type="hidden" name="pcode[]" id="pcode<?=$No;?>" value="<?=$result["p_code"];?>">
     <input type="hidden" name="txtreceive[]" id="txtreceive<?=$No;?>" value="<?=$receiveorder;?>"></td> 
	 <td>  <?=$result["p_name"];?></td>
     <td align="right"><?="".number_format($result["p_pricebuy"], 2,'.',',');?>  
	<input type="hidden" name="txtprice[]" id="txtprice<?=$No;?>" style="width:55px;text-align:right" value="<?="".number_format($result["p_pricebuy"], 2,'.',',');?>" disabled>
     </td>
     <td align="center">
<input type="text" name="txtqty[]" id="txtqty<?=$No;?>" style="width:30px;text-align:center" value="<?=$record["p_reqty"];?>" onKeyUp="checkNum()" disabled />
<input type="hidden" name="q" id="q<?=$No;?>" style="width:30px;text-align:center"  value="<?=$record["p_reqty"];?>"></td>
    
    <td align="right"><input type="text" name="txttotal" id="txttotal<?=$No;?>" style="width:65px;text-align:right"  value="<?="".number_format($record["p_pricere"], 2,'.',',');?>" disabled> 
<input type="hidden" name="txtstotal[]" id="txtstotal<?=$No;?>" value="<?=$record["p_pricere"];?>" style="width:65px;text-align:right"  />    
<input type="hidden" name="t" id="t<?=$No;?>" style="width:30px;text-align:center" value="<?="".number_format($record["p_pricere"], 2,'.',',');?>">
<input type="hidden" name="st" id="st<?=$No;?>" style="width:30px;text-align:center" value="<?=$record["p_pricere"];?>">
</td>
	</tr>
<?                         
$num++;                                 
$No++;			
								  
								  $strTotal=$strTotal+$record["p_pricebuy"];
								  $disTotal=($strTotal*$_SESSION["discount(%)"])/100;
								  $numTotal=$numTotal+$record['p_qtybuy'];
								  $priceTotal=$strTotal-$disTotal;
								  
}}
?>
        </table>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 04:49:08 | 
                        By :
                            Guest | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ช่วยดูให้ที....... ไม่อยากติด F โปรเจคอ่า T_T'''                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 05:02:57 | 
                        By :
                            pongyo | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 น้องครับ ลองเปลี่ยน For ดู ครับ 
 
จาก 
for(var a=no;a<=no;a++) 
เป็น 
for(var a=[b];a[b]<=titles.length;b++)                        
               
               | 
             
            
              
			                
  ประวัติการแก้ไข 2013-02-13 08:57:11 2013-02-13 08:58:52 2013-02-13 09:00:26              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 08:56:17 | 
                        By :
                            nutzaaclub | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 พี่ sakuraei  หนูลองแก้แล้ว ไม่ได้ค่ะ (ตรง4รายการเอ๋อเลยค่ะ พอติ๊ก CheckBox ตรงจำนวนเล่มก็ไม่สามารถแก้ได้ และก็ตรง 1รายการก็เหมือนเดิม ช่องจำนวนเล่มไม่เปิดให้แก้)  พยายามหาแล้วก็แก้ไม่ได้.... T_T                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 12:57:20 | 
                        By :
                            pongyo | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 รีบมากมั๊ย ถ้าให้พี่ช่วยจริงๆล่ะก็ พี่จะลื้อใหม่ทั้งหมด แล้วโค้ดจะสั้นลงเหลือครึ่งเดียว แต่ทำงานได้ทุกอย่าง 
 
ปล.ถ้าไม่รีบคืนนี้พี่จะมาแก้ไขให้ ระหว่างนี้ถ้ามีผู้รู้ท่านอื่นมาช่วยก็คงไม่ต้องรอนาน                          
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 13:15:36 | 
                        By :
                            sakuraei | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	     
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ทดลองดูน่ะครับ การใช้ JQuery มันจะสั้นมากๆเลย http://jsfiddle.net/f5TEm/ 
<!DOCTYPE HTML PUBtdC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title> New Document </title>
  <meta name="Generator" content="EditPlus">
  <meta name="Author" content="Unidentifier">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  <meta http-equiv="Content-Type" content="text/html; charset=utf8" />
  <style type="text/css">
	tr td {background-color:lemonchiffon; width:200px;}
	.number {text-align:right;padding-right:0.2em;width:60px;}
	.focusing{background:floralwhite;}
  </style>
  <script type="text/javascript">
  <!--
	$(document).ready(function(){
		$(":checkbox").change(function(){
			
			var curID = $(this).attr("for");
			var pname = $(this).parents("tr").find("input:eq(1)").val();
			if($(this).is(":checked")){
				alert("ท่านกำลังแก้ไขจำนวนสั่งซื้อ สินค้า '" +pname+"'");
				$("input.price_"+curID).removeAttr("readonly").addClass("focusing");
				$("input.qty_"+curID).removeAttr("readonly").addClass("focusing");
				$("input.total_"+curID).removeAttr("readonly").addClass("focusing");
				$("input.qty_"+curID).focus().select();
			}else{
				alert('un-checked');
				$("input.price_"+curID).attr({"readonly":true}).removeClass("focusing");
				$("input.qty_"+curID).attr({"readonly":true}).removeClass("focusing");
				$("input.total_"+curID).attr({"readonly":true}).removeClass("focusing");
			}
		});
	});
  //-->
  </script>
 </head>
 <body>
 <table>
  <tr for="item1001" class="items" >
  <td><input type="checkbox" name="buy[]" for="item1001" /></td>
  <td><input type="text" name="pname[]" readonly="readonly" value="รหัสลับดาร์วินชี่" /></td>
  <td><input type="text" name="price[]" readonly="readonly" class="price_item1001 number" value="220"  /></td>
  <td><input type="text" name="qty[]" readonly="readonly" class="qty_item1001 number " value="2" /></td>	
  <td><input type="text" name="total[]" readonly="readonly" class="total_item1001 number" value="440" /></td>	
  </tr>
  <tr for="item1301" class="items">
  <td><input type="checkbox" name="buy[]" for="item1301" /></td>
  <td><input type="text" name="pname[]" readonly="readonly" value="ความสุขของกระทิ" /></td>
  <td><input type="text" name="price[]" readonly="readonly" class="total_item1301 number" value="120"  /></td>
  <td><input type="text" name="qty[]" readonly="readonly" class="total_item1301 number" value="1" /></td>	
  <td><input type="text" name="total[]" readonly="readonly" class="total_item1301 number" value="120" /></td>	
  </tr>
  <tr for="item1021" class="items">
  <td><input type="checkbox" name="buy[]" for="item1021" /></td>
  <td><input type="text" name="pname[]" readonly="readonly" value="เสียดายคนตายไม่ได้อ่าน" /></td>
  <td><input type="text" name="price[]" readonly="readonly" class="total_item1021 number" value="180"  /></td>
  <td><input type="text" name="qty[]" readonly="readonly" class="total_item1021 number" value="1" /></td>	
  <td><input type="text" name="total[]" readonly="readonly" class="total_item1021 number" value="180" /></td>	
  </tr>
 </table>
 </body>
</html>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-13 14:23:01 | 
                        By :
                            sakuraei | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ทดลองตัดรายการหนังสือให้เหลือบรรทัดเดียวก็ได้ แล้วตรวจสอบดูว่า checkbox ทำงานปกติมั๊ย                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-14 08:46:46 | 
                        By :
                            sakuraei | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                      
 
ขอขอบคุณพี่ๆ ทุกท่านที่ให้การช่วยเหลือ  ตอนนี้ผมแก้ได้แล้วครับ ดีใจมาก!!!  
 
ยังไงผมก็ต้องขอขอบคุณอีกทีนะครับ !!!!                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-14 21:29:27 | 
                        By :
                            pongyo | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ดีใจด้วยครับ แต่ช่วยกลับมาบอกว่าแก้ไขจุดไหนบ้าง ก็จะเป็นวิทยาทานกับคนอื่นๆที่อาจเจอปัญหาเดียวกันน่ะครับ                         
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-14 21:44:49 | 
                        By :
                            sakuraei | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ผมก็บอกไม่ถูกอ่ะครับ ว่าเพื่อนแก้จุดไหน เพราะเพื่อนอีกคนเขียน  แต่ผมจะเอาโค้ดโพสไว้ครับ ^^ 
 
Code (PHP) 
<script language="javascript">
function checkFlag(pid)
{
	document.getElementById('fl').value = document.getElementById('flag'+pid).value;
}
function checkNum(pid)
{	
	var qty    = new Array();
	var   q    = new Array();
	var   t    = new Array();
	var  st    = new Array();	
	var price  = new Array();
	var titles =  frmbuy.elements['buy[]'];
	
	var num = document.getElementById('countrow').value - 1;
	//alert(num);
	
// for(var a=0;a<titles.length;a++){
	
//if(eval(document.getElementById('buy'+pid).checked)==true){		
	for(var i=0;i<num;i++){
		//alert(pid);
		price[i] = document.getElementById('txtprice'+pid).value;
	      qty[i] = document.getElementById('txtqty'+pid).value;
		    q[i] = document.getElementById('q'+pid).value;
			t[i] = document.getElementById('t'+pid).value;
		   st[i] = document.getElementById('st'+pid).value;
		    st[i] = document.getElementById('st'+pid).value;
			   
		  
	var    total = price[i]*qty[i];
		
		if(total==0){	
			document.getElementById('txttotal'+pid).value = ("0.00");
	
		}else{
			document.getElementById('txttotal'+pid).value = total.toLocaleString();
		}
		
		if(document.getElementById('txtqty'+pid).value.match(/^0/)){
			document.getElementById('txtqty'+pid).value=q[i];    
				 document.getElementById('txttotal'+pid).value=t[i];
					alert('จำนวนสินค้าที่ส่งคืน ต้องมีจำนวนมากกว่า 0');				
				 document.getElementById('txtqty'+pid).value=q[i];
				 document.getElementById('txttotal'+pid).value=t[i];
			   document.getElementById('txtstotal'+pid).value=st[i];
	    	   document.getElementById('txtqty'+pid).value.focus();
			return false;
		
		}
		if(!document.getElementById('txtqty'+pid).value.match(/^([0-9]+)$/)) {
	 		   document.getElementById('txtqty'+pid).value=q[i];
			    document.getElementById('txttotal'+pid).value=t[i];
			   document.getElementById('txtstotal'+pid).value=st[i];
			     alert('กรุณากรอก จำนวนสินค้าที่ส่งคืน ด้วยตัวเลขเท่านั้น');	
				 document.getElementById('txtqty'+i).value=q[i];
				 document.getElementById('txttotal'+pid).value=t[i];
			   document.getElementById('txtstotal'+pid).value=st[i];
	    	   document.getElementById('txtqty'+pid).value.focus();
			return false ;
		}
  		if(parseInt(document.getElementById('txtqty'+pid).value) > parseInt(document.getElementById('q'+pid).value)){
				 document.getElementById('txtqty'+pid).value=qty[i];
				 document.getElementById('txttotal'+pid).value=total.toLocaleString();
			   document.getElementById('txtstotal'+pid).value=st[i];
				 alert('คุณไม่สามารถกรอกจำนวนสินค้าที่ส่งคืน มากกว่า จำนวนสินค้าที่รับ');
				  document.getElementById('txtqty'+pid).value=q[i];
				   document.getElementById('txttotal'+pid).value=t[i];
			   document.getElementById('txtstotal'+pid).value=st[i];
	    	   document.getElementById('txtqty'+pid).value.focus();
			return false ;	
		}
    
	}
	
	} 
//	function opentext(pid)
//	{	
	//alert(pid);
//		if(eval(document.getElementById('buy'+pid).checked)==true){
//			document.getElementById('txtqty'+pid).disabled=false;
			//alert(pid);
//		}else{
//			document.getElementById('txtqty'+pid).disabled=true;
//		}
	
//	}
</SCRIPT>    
<?			while ($record=mysql_fetch_array($result_data)){
			$id_de = $record['redetail_id'];
			$id_or = $record['re_id'];
			$id_pro = $record['p_code'];
			$price_pro = $record['p_pricere'];
			$qty_or = $record['p_reqty'];	
			
		$sqlpro= "select * from tbl_product where p_code = '$id_pro' ";
 			$data=mysql_query($sqlpro);			
			while ($result=mysql_fetch_array($data)){
			$ppid=$result["p_code"];
			$_SESSION["ppid"]=$ppid;
			
?>
     <tr height="30" bgcolor="#FFFFCC">
     <td align="center" width="45"><input type="checkbox" name="buy[]" id="buy<?=$ppid;?>" value="<?=$ppid;?>" onclick="SelectChange('<?=$ppid;?>')"></td>
     <td align="center"><?=$num;?></td>
     <td align="center"><?=$result["p_code"];?>
     <input type="hidden" name="pcode" id="pcode" value="<?=$result["p_code"];?>">
     <input type="hidden" name="txtreceive[]" id="txtreceive<?=$ppid;?>" value="<?=$receiveorder;?>"></td> 
	 <td>  <?=$result["p_name"];?></td>
     <td align="right"><?="".number_format($result["p_pricebuy"], 2,'.',',');?>  
	<input type="hidden" name="txtprice[]" id="txtprice<?=$ppid;?>" style="width:55px;text-align:right" value="<?="".number_format($result["p_pricebuy"], 2,'.',',');?>" disabled>
     </td>
     <td align="center">
<input type="text" name="txtqty[]" id="txtqty<?=$ppid;?>" style="width:30px;text-align:center" value="<?=$record["p_reqty"];?>" onKeyUp="checkNum('<?=$ppid;?>')" disabled />
<input type="hidden" name="q" id="q<?=$ppid;?>" style="width:30px;text-align:center"  value="<?=$record["p_reqty"];?>"></td>
    
    <td align="right"><input type="text" name="txttotal" id="txttotal<?=$ppid;?>" style="width:65px;text-align:right"  value="<?="".number_format($record["p_pricere"], 2,'.',',');?>" disabled> 
<input type="hidden" name="txtstotal[]" id="txtstotal<?=$ppid;?>" value="<?=$record["p_pricere"];?>" style="width:65px;text-align:right"  />    
<input type="hidden" name="t" id="t<?=$ppid;?>" style="width:30px;text-align:center" value="<?="".number_format($record["p_pricere"], 2,'.',',');?>">
<input type="hidden" name="st" id="st<?=$ppid;?>" style="width:30px;text-align:center" value="<?=$record["p_pricere"];?>">
</td>
<td align="center" ><input type="text" name="flag[]" id="flag<?=$ppid;?>" onKeyUp="checkFlag('<?=$ppid;?>')" disabled>
</td>
	</tr>
<?                         
$num++;                                 
$No++;			
								  
								  $strTotal=$strTotal+$record["p_pricebuy"];
								  $disTotal=($strTotal*$_SESSION["discount(%)"])/100;
								  $numTotal=$numTotal+$record['p_qtybuy'];
								  $priceTotal=$strTotal-$disTotal;
								  
}
}
?>
<input type="hidden" value="<?php echo $num; ?>"  id="countrow"/> 
<input type="hidden" name="sum" id="sum" style="width:30px;text-align:center" value="0"> 
<input type="hidden" name="fl" id="fl" style="width:80px;text-align:center" value="">      </table>
        
        <br/>
        <table align="center"> 
    		<tr>
            	<td>
        	<input type="submit" value="  ยืนยันการส่งคืนสินค้า  "></form>
            	 </td>
                 <td height="30">
        	 <form method="post" action="a_show_return.php" enctype="multipart/form-data" name="form1" >         
            <input type="submit" value="    ย้อนกลับ    ">
            </form>
        		 </td>
           </tr>
    </table>
                        
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-14 23:05:22 | 
                        By :
                            pongyo | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 ขอบคุณครับ                          
               
               | 
             
            
              
			                              
                              
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2013-02-14 23:19:02 | 
                        By :
                            sakuraei | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     | 
   
 
                 |