Solved

Need Help Formatting the Results Page from a Partially Dynamically Created Form

Posted on 2004-08-11
5
216 Views
Last Modified: 2013-12-24
I'm trying to process a college withdrawl form.  The form is pulling the classes(CRNs) from a query, and then it is adding the grade drop down boxes and date input fields to go along with each individual CRN.  My problem is that I'm not really able to format the results page, in the way that I want to format it.  I can pull the information, but I really want to format it in a way that my users will understand it.  I might not be creating this dynamic form properly, so if you have suggestions on that, don't hesitate to share.

Here is a sample of the initial form:

My query is get_classes, and it is pulling the CRN, and then a CLASS Name for a particular student each term.

<FORM ACTION="wtest.cfm" METHOD=POST name="withdrwlform" id="withdrwlform">
<CFSET #classlist# = #valuelist(get_classes.class)#>
<CFSET #crnlist# = #valuelist(get_classes.crn)#>
<cfset #counter# = 1 ><CFLOOP index="i" list="#crnlist#">
       <CFIF #counter# LTE #get_classes.recordcount# >
       <CFOUTPUT>
             <tr>
      <td><input type=text name="class" value="#listgetat(classlist,counter)#"></td>
                      <td><div align="center">
                          <select name="grd" id="grd#i#">
                            <option value="A">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                            <option value="D">D</option>
                            <option value="F">F</option>
                            <option value="W" selected>W</option>
                            <option value="WF">WF</option>
                            <option value="WP">WP</option>
                          </select>
                     </td>
                      <td>
                          <select name="wegrd" id="wegrd#i#">
                            <option value="1" selected>1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                          </select>
                      </td>
                      <td>
<INPUT id=dc1 name="ldoa" size="12" value="<cfoutput>#DateFormat(now(),"DD-MMM-YYYY")#</cfoutput>" style="TEXT-ALIGN: center">
<INPUT onclick="popFrame.fPopCalendar('dc1','dc1',event);" type=button value=" V "> 
                      </td>
                  </tr>
<input type= "hidden" name="classlist" value="#listgetat(crnlist,counter)#">
  <cfset #counter# = #incrementvalue(counter)#>
      </cfoutput></CFIF></cfloop>

<INPUT TYPE="Submit" VALUE=" Submit Form">
        <INPUT TYPE="reset" VALUE="Clear Form">
    </FORM>
------------------------------------------------------------------------------
For my Results Page, I've tried doing several things.  I've tried looping through the FormFields, but I get multiple CRNs, when I do that.

I really want to be able to process the results in a table format:

CRN(1)   Grade for CRN(1)    WEGrade for CRN(1)     LDOA for CRN(1)
CRN(2)   Grade for CRN(2)    WEGrade for CRN(2)     LDOA for CRN(2)
CRN(3)   Grade for CRN(3)    WEGrade for CRN(3)     LDOA for CRN(3)

However, right now I get the results in more of a comma delimited format with all the CRNS on one line, then all the Grades on another line, and so forth.

Really all I'm doing is pulling the processed form field like #Form.class# or #Form.grd#, but I know that isn't correct.  I think I need to somehow change my form fields to look for my looped index, but I'm just not getting that right.  

If you can shed any light on this problem, I would really appreciate it.

For extra credit, I have a Javascript Pop Calendar that is associated with the date input box.  It will actually pull the date input box for each of the CRNs that are pulled, however, the PopCalendar will only allow you to change the first date input box, when you click on a date.  It would be great if that could work as well.
0
Comment
Question by:kgarnto
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 11778876
1) Remove # from inside ANY cf tag unless it is in quotes.

So

<CFSET #classlist# = #valuelist(get_classes.class)#>
<CFSET #crnlist# = #valuelist(get_classes.crn)#>
<cfset #counter# = 1 ><CFLOOP index="i" list="#crnlist#">
       <CFIF #counter# LTE #get_classes.recordcount# >

Becomes

<CFSET classlist = valuelist(get_classes.class)>
<CFSET crnlist = valuelist(get_classes.crn)>
<cfset counter = 1 ><CFLOOP index="i" list="#crnlist#"> <!--- notice these # stay)
       <CFIF counter LTE get_classes.recordcount >

2) Use a for loop instead of manually incrementing your counter

<cfloop index="counter" from="1" to="#get_classes.recordcount#">

3) Why put the data into a comma delimeted list?  You can just use the build in cfoutput loop feature.  SO your page would become :
<FORM ACTION="wtest.cfm" METHOD=POST name="withdrwlform" id="withdrwlform">
<cfoutput query="get_classes">
       <CFOUTPUT>
             <tr>
      <td><input type=text name="class" value="#class#"></td>
                      <td><div align="center">
                          <select name="grd" id="grd#currentrow#">
                            <option value="A">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                            <option value="D">D</option>
                            <option value="F">F</option>
                            <option value="W" selected>W</option>
                            <option value="WF">WF</option>
                            <option value="WP">WP</option>
                          </select>
                     </td>
                      <td>
                          <select name="wegrd" id="wegrd#currentrow#">
                            <option value="1" selected>1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                          </select>
                      </td>
                      <td>
<INPUT id=dc1 name="ldoa" size="12" value="#DateFormat(now(),"DD-MMM-YYYY")#" style="TEXT-ALIGN: center">
<INPUT onclick="popFrame.fPopCalendar('dc1','dc1',event);" type=button value=" V ">
                      </td>
                  </tr>
<input type= "hidden" name="classlist" value="#crn#">
</cfoutput>

<INPUT TYPE="Submit" VALUE=" Submit Form">
        <INPUT TYPE="reset" VALUE="Clear Form">
    </FORM>


0
 

Author Comment

by:kgarnto
ID: 11795243
Thanks mrichmon!

I took your advice and just used the loop feature through cfoutput, and it cleaned up my form so that I don't have multiple records.

However, I'm still having issues in formatting my results page the way that I want to.

From reading through several of the expert-exchange solutions, I've seen where others have suggested the Evaluate command for similar situations.  I've tried using it, but I get errors saying the currentrow is undefined.  Should I have somehow passed that through a hidden form field?

This is how I was trying to format the results page:
<CFOUTPUT>
     <CFLOOP INDEX="ListIndex" list="#FORM.FieldNames#">
       #Evaluate("FORM.GRD" & currentrow)# )<br>
     </cfloop>
</CFOUTPUT>

Thanks again for your help.
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 11795605
I would use the following syntax:

#Evaluate("FORM.GRD" & currentrow)# --BECOMES---> #Form['GRD' & currentrow]#

However, the problem is that you are looping through a list so the "currentrow" variable is not available (this is a query variable)

You need to reference a variable that does exists or change to loop over the query.

Notice that in my example I changed from a loop over a list to
<cfoutput query="get_classes">

and that way let the cfoutput do the looping which also lets you use the currentrow variable....
0
 

Author Comment

by:kgarnto
ID: 11797154
My results page doesn't have the original query, so I know now not to use currentrow.

You mentioned referencing an existing variable.  I'm passing the classlist, which is all the CRNS.

If I set up my results page like this, it tells me that the variables don't exist.

<CFIF ISDefined("Form.CLASSLIST")>
  <table border="1">
    <CFOUTPUT>
      <CFLOOP Index="i" List="#Form.CLASSLIST#">
        <tr>
            <td>#Form.Class#</td>
            <td>#Evaluate("FORM.GRD" & i)#</td>
            <td>#Evaluate("FORM.WEGRD" & i)# </td>
            </tr>
      </CFLOOP>
    </CFOUTPUT>
  </table>
</CFIF>

If I stay with using a loop through query on my forms page, how can I name my fields so that I can obtain them in the results page?  Or do I need to go back to using an index loop?  I've tried going back to the index loop but I still run into problems with variables not existing when processing the results page.
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 250 total points
ID: 11797546
On the main page you use the currentrow to name the fields like this :

<cfoutput query="get_classes">
             <tr>
      <td><input type=text name="class" value="#class#"></td>
                      <td><div align="center">
                          <select name="grd" id="grd#currentrow#">
                            <option value="A">A</option>
                            <option value="B">B</option>
                            <option value="C">C</option>
                            <option value="D">D</option>
                            <option value="F">F</option>
                            <option value="W" selected>W</option>
                            <option value="WF">WF</option>
                            <option value="WP">WP</option>
                          </select>
                     </td>
... rest of table here

</cfoutput>

Then include a hidden variable like this :

<input type="hidden" name="counter" value="#getclasses.recordcount#">

Then on the results page do a loop

<cfloop index="i" from="1" to="#form.counter#">
 <CFOUTPUT>
 
        <tr>
          <td>#Form.Class#</td>
          <td>#FORM['GRD' & i]#</td>
          <td>#FORM['WEGRD' & i]# </td>
          </tr>

    </CFOUTPUT>
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question