2016-06-10 111 views
0

我需要知道如何傳遞日期while循環通過JavaScript到彈出頁面,並將其放在彈出窗口中的<P>標記內?通過JavaScript傳遞數據到彈出頁面while循環

<div class="header-img" align="center"> 

<img src="header.png" width="300"> 

</div> 
<div class="maincontent" align="right"> 
<?php 
include 'config.php'; 

$con->set_charset('utf8'); 
$sql = "SELECT * FROM de40v_subventions order by id desc"; 
$names = mysqli_query($con,$sql); 
while($row = mysqli_fetch_array ($names)){ 


?> 
<table class="maintable" align="right" width="400px" dir="rtl"> 
<form name="form" method="post" action="delconfirm.php" onSubmit="return checknone();"> 
<tr> 
<td> <label> <b>الرقم: </b> </label> </td> 
<td> <input type="text" value="<?php echo $row['id'] ?>" class="inputid" readonly/> </td> 
</tr> 
<tr> 
<td> <label> <b>التاريخ والوقت: </b> </label> </td> 
<td> <p> <?php echo date("Y-m-d H:m:s" , $row['datetime']); ?> </p> </td> 
</tr> 
<tr> 
<td> <label> <b> الإسم كاملاً:</b> </label> </td> 
<td> <p id="name"> <?php echo $row['firstname'] . ' ' . $row['fathername'] . ' ' . $row['grandfathername'] . ' ' . $row['familyname'] ?> </p> </td> 
</tr> 
<tr> 
<td> <label> <b> رقم الهوية:</b> </label> </td> 
<td> <p id="identity"> <?php echo $row['identity'] ?> </p> </td> 

......... 


<script type="text/JavaScript"> 

function openprint(){ 

    var popupwin = window.open("","طباعة البيانات","width=700, height=400"); 

    popupwin.document.writeln('<html><head><title>طباعة البيانات</title></head> <body> <center> <p id="printname"></p> </center> </body> </html>'); 
    popupwin.document.close(); 
    popupname = popupwin.document.getElementById('printname').innerHTML; 
    name = document.getElementById('name').innerHTML; 
    popupname = name; 

} 

<?php } ?> 
+0

不太清楚你想在這裏實現什麼。你在哪裏調用'openprint()'?既然您重新創建了JS,每次迭代結果時都會打開彈出窗口,爲什麼不直接在窗口內打印日期呢? – jeesus

+0

@jeesus這裏的問題沒有顯示在彈出頁面上 – ali

回答

1

實際上,在彈出的頁面上顯示的東西,你只是沒有傳遞任何實際可見的內容。試試這個:

popupwin.document.getElementById('printname').innerHTML = 'put your date or content here'; 

並把它放在你的writeln()之後。