弹出页面php数据不会在提交时显示

时间:2012-05-11 15:50:44

标签: php javascript html

我有一个表从mysql获取了php变量,该表位于Form内,我想要做的是显示要为发票样式的用户打印的页面布局,我试图做一个行为,当提交FORM时,弹出页面将显示php variables data,这根本不起作用,我试图显示{{1在一个regluar页面内的弹出页面,它工作! ,这意味着我的PHP代码没有问题。

这是表单页面代码:

content

这是弹出窗口代码(要打印的发票布局):

<form action="../../printInvoice.php" method="post" onsubmit="MM_openBrWindow('../../printInvoice.php','Invoice','status=yes,scrollbars=yes')">
<table width="100%" border="0">
<tr>
    <td align="left">Invoice:</td>
  </tr>
  <tr>
    <td width="12%" height="39" bgcolor="#9DE3FB" align="center">Invoice Number</td>
    <td width="12%" bgcolor="#9DE3FB" align="center">Event Name</td>
    <td width="12%" bgcolor="#9DE3FB" align="center">Reservation Date</td>
    <td width="12%" bgcolor="#9DE3FB" align="center">Quantity</td>
    <td width="12%" bgcolor="#9DE3FB" align="center">Price Per Ticket</td>
    <td width="12%" bgcolor="#9DE3FB" align="center">Total Price</td>
  </tr>
  <tr>
    <td width="12%" height="39" align="center"><input type="text" name="invoiceId" readonly="readonly" value="<? echo $row['invoiceId']; ?>" class ="field-style"/></td>
    <td width="12%" height="39" align="center"><input type="text" name="eventTitle" readonly="readonly" value="<? echo $row['name']; ?>" class="field-style" /></td>
    <td width="12%" height="39" align="center"><input type="text" name="invoiceDate" readonly="readonly" value="<? echo $row['invoiceDate']; ?>" class="field-style" /></td>
    <td width="12%" height="39" align="center"><input type="text" name="invoiceqty" readonly="readonly" value="<? echo $row['quantity'] ?>" class="field-style" /></td>
    <td width="12%" height="39" align="center"><input type="text" name="invoicePPU" readonly="readonly" value="<? echo $row['price']; ?>" class="field-style" /></td>
    <td width="12%" height="39" align="center"><input type="text" name="invoiceTotal" readonly="readonly" value="<? echo $row['totalPrice']; ?>" class="field-style" /></td>
  </tr>
</table>
<br />
<input type="submit" value="Print Invoice" />
</form>

用于提交行为,我使用了Dreamweaver行为面板。这有什么不对?

4 个答案:

答案 0 :(得分:0)

你不能使用php来显示弹出窗口,你必须使用ajax和javascript:

http://jquery.malsup.com/form/

    $(document).ready(function() { 
        // bind 'myForm' and provide a simple callback function 
        $('#myForm').ajaxForm(function() { 
           //show your Popup
        }); 
    }); 

答案 1 :(得分:0)

  

您是否尝试在弹出窗口中使用$row['invoiceId']; $invoiceId的实例?

     

它似乎是同一个文件,因此$ row []数据应该是可访问的!

     

如果这不起作用,我们可能需要更多代码,尤其是php端。

^^忽略了一些东西,我们肯定需要更多代码!

答案 2 :(得分:0)

我不确定Dreamweaver的行为,但据我所知,这将无法正常工作。

您正在将数据发布到“../../printInvoice.php”,但是当您请求弹出页面时,您正在打开一个尚未收到帖子数据的新实例。

您需要更改弹出页面的javascript,以便在执行弹出请求时发布表单数据。

我不知道您使用哪个库来创建弹出窗口,但是fancybox(Jquery插件:http://fancybox.net)允许您将数据发布到它创建的弹出窗口。

如果你能告诉我你正在使用什么弹出式库,我可能会进一步提供帮助。

答案 3 :(得分:0)

谢谢,而不是所有这些,我将所有变量发布为url参数,例如:

<onsubmit="MM_openBrWindow('../../printInvoice.php?invoiceId=<? echo $row['invoiceId']; ?>&eventTitle=<? echo $row['name']; ?>','Invoice'

感谢您的尝试&amp;你的每个人的时间:)。