|  |  | 
          
            | คือจะทำหน้า popup ให้เค้ากรอกจำนวน อุปกรณ์ ที่ต้องการ แล้วกด submit  ในหน้า popup เพื่อไปอัพเดตข้อมูลคงเหลือปัจจุบัน   ปัญหาคือ ตอนกด submit แล้ว  ข้อมูลมันไม่ไปโชว์ในหน้าหลักให้ เหมือนมัน ไม่เรียกใช้ java script ให้ 
 หน้าหลัก
 page1.php
 
 
<script type="text/javascript">
		function popup(url,name,windowWidth,windowHeight){    
				myleft=(screen.width)?(screen.width-windowWidth)/2:100;	
				mytop=(screen.height)?(screen.height-windowHeight)/2:100;	
				properties = "width="+windowWidth+",height="+windowHeight;
				properties +=",scrollbars=yes, top="+mytop+",left="+myleft; 
				window.open(url,name,properties);
		}
</script>
<form  method="post" name="frmain">
	(1)
	<input type="text" name="tx1_1"  class="tx"  readonly>
    <input type="text" class="tx1" name="tx1_2"   readonly>
    <input type="text" class="tx" value="" name="tx1_3" size="5" readonly>
    <br>
    (2)
	<input type="text" name="tx2_1"  class="tx"  readonly>
    <input type="text" class="tx1" name="tx2_2"   readonly>
    <input type="text" class="tx" value="" name="tx2_3" size="5" readonly>
    <br>
    (3)
	<input type="text" name="tx3_1"  class="tx"  readonly>
    <input type="text" class="tx1" name="tx3_2"   readonly>
    <input type="text" class="tx" value="" name="tx3_3" size="5" readonly>
    <br>
    <a href="javascript:popup('popup_1.php','',505,500)" style="color:#000000"  class="bt1">กดเลือกอุปกรณ์ </a>
    
    
</form>
 
 
 popup_1.php
 
 
<form method="post" name="ffrmain" action="popup_2.php" >	
		<?
				include("connect.php");
				$sql ="select * from device";
				$sqlQuery = mssql_query($sql); 
		?>
				<table border="1" cellspacing="0">
                	<tr bgcolor="#FFFFCC "id="table"> 
                		<th><center>รายการอุปกรณ์</center></th>
                		<th><center>จำนวนคงเหลือ</center></th>
                		<th><center>จำนวณที่ต้องการยืม</center></th>
                	</tr>
		<?	
				$i=1;
				while($data = mssql_fetch_array($sqlQuery)){
				
		?>
        		<tr>
                	<input type="hidden" value="<?=$data["id"]?>" name="id[]">
                	<td><center><input type="text" value="<? echo $data["Product_name"]?>" style="border:hidden" name="Product_name" readonly></center></td>
					<td><center><input type="text" value="<? echo $data["Product_stock"]?>" style="border:hidden" name="total_stock" readonly></center></td>
                    <td><input type="text" name="inputUnit[]" ></td>
             	</tr>
        <?
					$i++;
					
        			}
				echo "</table>";
				mssql_close();
				
		?>
        
        <center><input type="submit" value="ตกลง">
        <input type="button" value="ยกเลิก" name="cal" onClick="window.close();"></center>
     </form>   
  
 
 
 popup_2.php
 
 
<script language="javascript">
	function updateOpener() {
				window.opener.document.frmain.txt1_1.value=document.farmain.pn[0].value;
				window.opener.document.frmain.txt2_1.value=document.farmain.pp[0].value;
				window.opener.document.frmain.txt3_1.value=document.farmain.ini[0].value;
				
				window.opener.document.frmain.txt1_2.value=document.farmain.pn[1].value;
				window.opener.document.frmain.txt2_2.value=document.farmain.pp[1].value;
				window.opener.document.frmain.txt3_2.value=document.farmain.ini[1].value;
				
				window.opener.document.frmain.txt1_3.value=document.farmain.pn[2].value;
				window.opener.document.frmain.txt2_3.value=document.farmain.pp[2].value;
				window.opener.document.frmain.txt3_3.value=document.farmain.ini[2].value;
				
				
				window.close();
	}
	
</script>
<form method="post" name="farmain">
<?
	include("connect.php");
	$sql_select_handset = "select * from device";
	$sql_queary_handset = mssql_query($sql_select_handset);
	$i=0;
	while($data_handset=mssql_fetch_array($sql_queary_handset)){
		if(!empty($_POST['inputUnit'][$i])){
?>
			<? $id=$data_handset['id'];?>
			<input type="hidden" name="pn[]" value="<?=$Product_name=($data_handset['Product_name']);?>"> 
            <input type="hidden" name="pp[]" value="<?=$Product_Price=($data_handset['Product_price']);?>">
			<? $Stock_borrow=($data_handset['Product_stock']);?>
			<input type="hidden" name="ini[]" value="<?=$inputUnit=($_POST['inputUnit'][$i]);?>" >
			<? $totalstock =$Stock_borrow-$inputUnit;?>
<?			
			$sql_update_handset ="update device set Product_stock='$totalstock' where id='$id'";
			$sql_quary_handset =mssql_query($sql_update_handset);
		}
		$i++;
	}
?>
<center><input type="submit" value="Close" onClick="Javascript:updateOpener()" ></center>
</form>
 
 
  
 
  
 
  
 
 
 Tag : Ms SQL Server 2008
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2014-07-09 15:00:01 | By :
                          pongyakuza | View :
                          2903 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |