0

我有一个表有从中提取的 php 变量mysql,表在里面Form,我想做的是显示要为用户打印的具有发票样式布局的页面,我试图做出一个行为,当FORM提交,弹出页面会显示php variables data,这根本不起作用,我尝试在常规页面中显示content弹出页面,它起作用了!,这意味着我的 php 代码没有问题。

这是表单页面代码:

<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>

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

<table width="65%" border="1" cellspacing="5" cellpadding="5">
  <tr>
    <td colspan="5"><table width="100%" border="0" cellspacing="5" cellpadding="5">
      <tr>
        <td width="60%"><img src="images/Logo.png" /></td>
        <td width="40%"><p>Invoice No:# <? echo $invoiceId; ?></p>
          <p>Invoice Date: <? echo $invoiceDate ;?> </p></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="125" colspan="5" valign="top"><p>Bill To:</p>
    <p>Name:</p>
    <p>Address:</p></td>
  </tr>
  <tr>
    <td width="12%" align="center" height="40">Item Id</td>
    <td width="28%" align="center">Item Disc</td>
    <td width="9%" align="center">QTY</td>
    <td width="40%" align="center">Price Per Unit</td>
    <td width="11%" align="center">Total</td>
  </tr>
  <tr>
    <td align="center" valign="middle">1</td>
    <td align="center" valign="middle"><? echo $eventTitle . " ticket(s)"; ?></td>
    <td align="center" valign="middle"><? echo $invoiceqty ; ?></td>
    <td align="center" valign="middle"><? echo $invoicePPU ; ?></td>
    <td align="center" valign="middle"><? echo $invoiceqty * $invoicePPU ; ?></td>
</tr>
 </table>

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

4

4 回答 4

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
        }); 
    }); 
于 2012-05-11T15:56:31.997 回答
0

您是否尝试过在弹出窗口中使用$row['invoiceId'];instaed $invoiceId

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

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

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

于 2012-05-11T15:59:49.857 回答
0

我不确定 Dreamweaver 的行为,但据我所知,这永远不会奏效。

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

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

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

如果您能告诉我您正在使用哪个弹出库,我可能会提供进一步的帮助。

于 2012-05-11T16:02:39.117 回答
0

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

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

感谢大家的尝试和时间:)

于 2012-05-11T16:11:31.400 回答