Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic form taking a long time to generate

Explorer ,
Feb 04, 2011 Feb 04, 2011

Hi all, I have a <cfoutput query="blah"> wrapped around a <cfform> which can retireve anything upto 200 rows from the datatbase... My problem is if I retrieve anything more than 30ish rows then my page takes ages to compile and will hang.  Can you guys take a look at my code and see if it can be improved or if I am doing anything wrong please ?  I inherited this code from the previous developer...

Many Thanks,

G

<!--- update previous address --->
<cfif isdefined("btnUpdAddr")>
<cfmodule name="updPrevAddr" address1="#form["address1#addrCount#"]#" address2="#form["address2#addrCount#"]#"
  town="#form["town#addrCount#"]#" county="#form["county#addrCount#"]#" postcode="#form["postcode#addrCount#"]#"
  residentfrom="#form["ataddrsince#addrCount#"]#" residentto="#form["ataddrto#addrCount#"]#"
  country="#form["country#addrCount#"]#" previousaddrid="#form.addrid#" applicationid="#form.appid#">
</cfif>

<!--- loop round and get addressess --->

<cfoutput query="getPreviousAddresses">
   <cfform name="fmAddr#addrCount#" action="previousaddresses.cfm" class="css_fm1" onSubmit="return FormAddrValidate('#addrCount#')">
    <fieldset>
    <legend>Address #addrCount#</legend>
   
    <p><label for="address1#addrCount#" class="txtlabel"><span class="reqd">*</span> Address line 1</label>
    <cfinput id="address1#addrCount#" name="address1#addrCount#" type="text" class="txt" title="Previous address" value="#address1#" required="Yes" validate="regex" pattern="(^[A-Z0-9\(\)\-/'&]+$)|(^[A-Z0-9\(\)\-/'&][A-Z 0-9\(\)\-/'&]*[A-Z0-9\(\)\-/'&]$)" message="Please enter a valid Address line 1." maxlength="60" onChange="javascript:this.value=this.value.toUpperCase();trim(this);" /></p>
   
    <p><label for="address2#addrCount#" class="txtlabel">Address line 2</label>
    <cfinput id="address2#addrCount#" name="address2#addrCount#" type="text" class="txt" title="Previous address" value="#address2#" validate="regex" pattern="(^[A-Z0-9\(\)\-/'&]+$)|(^[A-Z0-9\(\)\-/'&][A-Z 0-9\(\)\-/'&]*[A-Z0-9\(\)\-/'&]$)" message="Please enter a valid Address line 2." maxlength="60" onChange="javascript:this.value=this.value.toUpperCase();trim(this);" /></p>
   
    <p><label for="town#addrCount#" class="txtlabel"><span class="reqd">*</span> Town</label>
    <cfinput id="town#addrCount#" name="town#addrCount#" type="text" class="txt" title="Previous town" value="#town#" required="Yes" validate="regex" pattern="(^[A-Z0-9\(\)\-/'&]+$)|(^[A-Z0-9\(\)\-/'&][A-Z 0-9\(\)\-/'&]*[A-Z0-9\(\)\-/'&]$)" message="Please enter a valid Town." maxlength="30" onChange="javascript:this.value=this.value.toUpperCase();trim(this);" /></p>
   
    <p><label for="county#addrCount#" class="txtlabel">County</label>
    <cfinput id="county#addrCount#" name="county#addrCount#" type="text" class="txt" title="Previous county" value="#county#" required="No" validate="regex" pattern="(^[A-Z0-9\(\)\-/'&]+$)|(^[A-Z0-9\(\)\-/'&][A-Z 0-9\(\)\-/'&]*[A-Z0-9\(\)\-/'&]$)" message="Please enter a valid County." maxlength="30" onChange="javascript:this.value=this.value.toUpperCase();trim(this);" /></p>
   
    <!--- COUNTRY --->    
    <p><label for="country#addrCount#" class="txtlabel"><span class="reqd">*</span> Country</label>
    <cfmodule name="hccpass.getISOCountries" queryname="getISOCountries">
    <cfselect id="country#addrCount#" name="country#addrCount#" title="Previous country" query="getISOCountries" display="country" value="code" size="1" selected="#countryiso#" message="Please select a Country." required="Yes">
     <cfif countryiso eq "">
      <option value="0" selected></option>
     </cfif>
    </cfselect></p>
   
    <p><label for="postcode#addrCount#" class="txtlabel">Postcode</label>
    <cfinput id="postcode#addrCount#" name="postcode#addrCount#" type="text" title="Previous postcode" value="#postcode#" maxlength="30" size="30" message="Please enter a valid Postcode." onChange="javascript:this.value=this.value.toUpperCase();trim(this);" /></p>
       
    <p><label for="ataddrsince#addrCount#" class="txtlabel"><span class="reqd">*</span> At address from</label>
    <cfinput id="ataddrsince#addrCount#" name="ataddrsince#addrCount#" type="text" title="At address from date mm/yyyy" value="#residentfrom#" maxlength="7" size="7" mask="99/9999" required="Yes" validate="regex" pattern="^(0[1-9]|1[012])\/(19|20)\d\d$" message="Please enter a valid At address from (mm/yyyy)." />
   
    <div class="checkbox_label">  <span class="reqd">*</span> to  </div>
    <cfinput id="ataddrto#addrCount#" name="ataddrto#addrCount#" type="text" title="At address to date mm/yyyy" value="#residentto#" maxlength="7" size="7" mask="99/9999" required="Yes" validate="regex" pattern="^(0[1-9]|1[012])\/(19|20)\d\d$" message="Please enter a valid At address to (mm/yyyy)." /></p>
   
    <!--- hidden values for update --->
    <input type="hidden" name="addrCount" value="#addrCount#">
    <input type="hidden" name="appid" value="#appid#">
    <input type="hidden" name="applicantid" value="#applicantid#">
    <input type="hidden" name="addrid" value="#previousaddressesid#">
   
    <!--- no update option for read only user --->
    <cfif session.roleID neq 3 and tAllowAmend neq "N">
     <p><input type="submit" name="btnUpdAddr" class="fmbutton" title="Save this address" value="Save address" />
     <input type="button" name="btnDeleteAddr" class="fmbutton" title="Delete address" value="Delete" onclick="javascript: if (confirm('You are about delete a previous address. Click OK to continue.')) location='previousaddresses.cfm?appid=#appid#&applicantid=#applicantid#&prevaddrid=#previousaddressesid#'"/>
     <input type="reset" name="btnreset" class="fmbutton" title="Reset" /></p>
    </cfif>
    </fieldset>
    <cfset addrCount = addrCount+1> 
   </cfform>
</cfoutput>

709
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 04, 2011 Feb 04, 2011

Well the first thing that jumps out at me is that you're making a new form for every row in the query -- and since you're using cfform you're generating a whole heck of a lot of script (generated by using cfform) so I can see that slowing things down.



I think this is something better suited for a table which displays the records and links to an 'edit' page for an individual record instead of creating 200+ forms on one page.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 04, 2011 Feb 04, 2011
LATEST

It also looks like you are running queries inside your loop.  That usually slows things down.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources