2

我正在寻找cfform使用cfpdfform. 这是我的小测试页面,它遍历 50 条记录以提取名字和姓氏。我正在尝试将它们拉入pdf字段。目前,它将所有 50 个名字放入 firstname 字段,并将所有姓氏放入 pdf 的 lastname 字段。我没有与提交按钮结婚,但有什么更好的选择?

在我的最后一次迭代中,我将引入大约 100 个字段。

- 形式 -

<cfform name="autopdf" method="POST" action="automated_pdf_submit.cfm" enctype="multipart/form-data">
        <h1>Select a state to insert into a PDF form</h1>
        <div class="center">
            <select name="pdfselect" id="pdfselect">
                <option value="" selected>--Select State--</option>                 
                <option value="FROI_NY.pdf">New York</option>
                <option value="FROI_PA.pdf">Pennsylvania</option>
            </select>
            <cfinput type="hidden" name="statevalidate" onValidate="yourFunction" 
                     message="YOU MUST SELECT A STATE TO CONTINUE!">
        </div>
        <table align="center" style="width:400px">
            <tr>
                <th></th>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Export to PDF</th>
            </tr>
            <cfoutput>
            <cfloop query="#qryPersons#" startrow="1" endrow="50" >
                <tr class="#IIf(CurrentRow Mod 2, DE('rowOdd'), DE('rowEven'))#" onmouseover="this.className='rowHighlight'" 
                    <cfif CurrentRow Mod 2>onmouseout="this.className='rowOdd'"
                    <cfelse>onmouseout="this.className='rowEven'"</cfif>>
                        <td>#qryPersons.CurrentRow#</td>
                        <td>#qryPersons.LastName#</td>
                        <input type="hidden" name="FirstName" value="#qryPersons.LastName#">
                        <td>#qryPersons.FirstName#</td>
                        <input type="hidden" name="LastName" value="#qryPersons.FirstName#">
                        <td style="width:50px"><input type="submit" value="Create PDF"</td>
                </tr>
            </cfloop>   
            </cfoutput>
        </table>
</cfform>

- 行动 -

<cfpdfform action="populate" source="forms\#form.pdfselect#">
    <cfpdfformparam name="FirstName" value="#form.FirstName#">
    <cfpdfformparam name="LastName" value="#form.LastName#">
</cfpdfform>
4

1 回答 1

5

您的表单字段都已命名FirstNameLastName您需要使这些字段独一无二

<cfloop query="#qryPersons#" startrow="1" endrow="50" >
 <tr class="#IIf(CurrentRow Mod 2, DE('rowOdd'), DE('rowEven'))#" onmouseover="this.className='rowHighlight'" 
  <cfif CurrentRow Mod 2>onmouseout="this.className='rowOdd'"
  <cfelse>onmouseout="this.className='rowEven'"</cfif>>
  <td>#qryPersons.CurrentRow#</td>
  <td>#qryPersons.LastName#</td>
  <input type="hidden" name="FirstName#qryPersons.currentrow#" value="#qryPersons.LastName#">
  <td>#qryPersons.FirstName#</td>
  <input type="hidden" name="LastName#qryPersons.currentrow#" value="#qryPersons.FirstName#">
  <td style="width:50px"><input type="submit" value="Create PDF"</td>
  </tr>
</cfloop> 

我以前从未使用过 cfpdfform,但这种语法应该可以工作。您可能还需要动态命名name下面的属性

<cfpdfform action="populate" source="forms\#form.pdfselect#">
 <cfloop from="1" to="50" index="i">
    <cfpdfformparam name="FirstName" value="#form['FirstName'&i]#">
    <cfpdfformparam name="LastName" value="#form['LastName'&i]#">
 </cfloop>
</cfpdfform>
于 2013-02-22T16:36:56.493 回答