Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-08-11
5
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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

Optimum High-Definition Video Viewing and Control

The ATEN VM0404HA 4x4 4K HDMI Matrix Switch supports 4K resolutions of UHD (3840 x 2160) and DCI (4096 x 2160) with refresh rates of 30 Hz (4:4:4) and 60 Hz (4:2:0). It is ideal for applications where the routing of 4K digital signals is required.

Question has a verified solution.

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

What You Need to Know when Searching for a Webhost Provider
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

670 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