gpt4 book ai didi

ColdFusion - 使用具有多个字段和多个提交按钮的 cfloop

转载 作者:行者123 更新时间:2023-12-02 05:13:26 26 4
gpt4 key购买 nike

我希望使用 cfpdfformcfform 中的表单值传递给 PDF。这是我的小测试页,循环遍历 50 条记录以提取名字和姓氏。我正在尝试将它们拉入 pdf 字段。目前它将所有 50 个名字放入 firstname 字段,将所有 lastnames 放入 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>

-- Action --

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

最佳答案

您的表单字段都被命名为 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>

关于ColdFusion - 使用具有多个字段和多个提交按钮的 cfloop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15028753/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com