문제

I'm looking to pass form values in a cfform to a PDF using cfpdfform. Here's my little test page that loops through 50 records to pull the first and last name. I'm trying to just pull those into the pdf fields. Currently it puts in all 50 of the first names into the firstname field and all of the lastnames into the lastname field of the pdf. I'm not married to the submit button, but what are better options?

In my final iteration of this I'll be pulling in about 100 fields.

--Form--

<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>
도움이 되었습니까?

해결책

Your form fields are all named FirstName and LastName you need to make those unique

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

I've never used cfpdfform before, but this syntax should work. You may need to dynamically name the name attribute below as well

<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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top