Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CF Forms

Status
Not open for further replies.

iao

Programmer
Feb 23, 2001
111
US
Hi All. I am a relatively new user to CF. I have created a form where users select items from a pickbox and and then these items selected are carried over onto the second form where properties can be added for each item.

So, my code on the second form has the following:

<CFLOOP LIST=&quot;#form.list2#&quot; INDEX=&quot;x&quot;>
<CFOUTPUT>
<option VALUE=&quot;#x#&quot;>#x#</option>
</CFOUTPUT>
</CFLOOP>

This displays all the items selected from the first form onto the second form. When the users have added/updated each item, they press an [Add] button which redraws the form and the added properties are added to a table which is redrawn and displayed on the form.

However, this is the problem. When the form is redrawn, #form.list2# doesn't exist anymore. It only exists the first time I enter onto this second form. So, obviously, I get an error every time the [Add] button is selected. This is probably a simple problem to fix, but I can't seem to figure out the best way to resolve this. Any ideas? Thanks in advance.
 
I'm away from all ColdFusion books right now, but I think this is the general direction for the second page. If I understand you correctly, list2 was a multi select that was submitted from your first page. So that just means you also need to submit the values from your second page too to populate the drop down list.


<CFLOOP LIST=&quot;#form.list2#&quot; INDEX=&quot;x&quot;>
<CFOUTPUT>
<cfset newlist = newlist & &quot;,&quot; & #form.list2#>
<option VALUE=&quot;#x#&quot;>#x#</option>
</CFOUTPUT>
</CFLOOP>

<input type=&quot;hidden&quot; name=&quot;list2&quot; value=&quot;#newlist#&quot;>

Hope this at least points you in the right direction. :)
 
Well, you understood my problem correctly, but I guess I don't understand your answer (I'm sorry).

I don't understand how the CFSET newlist statement is going to work. When I first enter this form after selecting the values from the fist form, how will CF recognize or understand what newlist is?

In fact, I tried it and received an error (error resolving parameter NEWLIST). Am I doing something wrong, or am I just not understanding you correctly?
 
I'll give this scenario a try when I go to work today, but in the mean time, try using pound signs around newlist. I forgot ColdFusion cannot recognize a variable in a CFOutput statement without the pound sounds. Try adding #'s around newlist.

<cfset #newlist# = #newlist# & &quot;,&quot; & #form.list2#>

What I was hoping to do was populate #newlist# with the dropdown list values that were submitted from the first page. When the second page is submitted, I wanted to send a hidden field of the same name (list2) and value (newlist) as the form.list2 from the first page.

I thought your drop down list didn't have values on subsequent submissions because the second page does not actually have a form field named list2.

Anyway, I'll see what I can do about it when I get to work and I'll be sure to check back in. Also, if you could send the code you're using, that would help tremendously.

Later!
 
Ok here is the code. It is a bit sketchy as it's still primarily in the design phase and I haven't added any queries yet. Thanks so much for any help!

<FORM ACTION=&quot;Dsp_Addresses.cfm&quot; METHOD=&quot;post&quot; NAME=&quot;yourform&quot; ID=&quot;yourform&quot;>
<TABLE>
<TR>
<TD></TD>
<TD></TD>
<TD WIDTH=&quot;350&quot;>
<TABLE CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot;>
<TR BGCOLOR=&quot;lightgrey&quot;>
<TD></TD>
<TD><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot;>FName</FONT></TD>
<TD><INPUT NAME=&quot;FName&quot; MAXLENGTH=&quot;32&quot; SIZE=&quot;32&quot; ></TD>
<TD></TD>
</TR>
<TR BGCOLOR=&quot;EAEAEA&quot;>
<TD></TD>
<TD><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot;>LName</FONT></TD>
<TD><INPUT NAME=&quot;LName&quot; MAXLENGTH=&quot;32&quot; SIZE=&quot;32&quot; ></TD>
<TD></TD>
</TR>
<TR BGCOLOR=&quot;lightgrey&quot;>
<TD></TD>
<TD><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot;>Address</FONT></TD>
<TD><INPUT NAME=&quot;Address&quot; MAXLENGTH=&quot;32&quot; SIZE=&quot;32&quot; ></TD>
<TD>&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR=&quot;EAEAEA&quot;>
<TD></TD>
<TD><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot;>City</FONT></TD>
<TD><INPUT NAME=&quot;City&quot; MAXLENGTH=&quot;32&quot; SIZE=&quot;32&quot; ></TD>
<TD>&nbsp;&nbsp;</TD>
</TR>
<TR BGCOLOR=&quot;lightgrey&quot;>
<TD>&nbsp;&nbsp;</TD>
<TD><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot;>Phone</FONT></TD>
<TD><INPUT NAME=&quot;Phone&quot; MAXLENGTH=&quot;10&quot; SIZE=&quot;10&quot; ></TD>
<TD>&nbsp;&nbsp;</TD>
</TR>
</TABLE>
</TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD>
<SELECT NAME=&quot;picked_names2&quot;
MULTIPLE
STYLE=&quot;color:gray&quot;
STYLE=&quot;WIDTH:200&quot;
STYLE=&quot;Height:170&quot;>
<CFSET ref=0>
<CFLOOP LIST=&quot;#form.list2#&quot; INDEX=&quot;x&quot;>
<CFSET ref=ref+1>
<CFOUTPUT>
<CFSET #newlist# = #newlist# & &quot;,&quot; & #form.list2#>
<option VALUE=&quot;#ref#&quot;>#ref#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#x#</option>
</CFOUTPUT>
</CFLOOP>
<input TYPE=&quot;Hidden&quot; NAME=&quot;list2&quot; VALUE=&quot;#newlist#&quot;>
</SELECT>
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD><INPUT TYPE=&quot;submit&quot; VALUE=&quot;Add to List&quot;>&nbsp;<INPUT TYPE=&quot;Reset&quot; VALUE=&quot;Clear&quot;></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
<TD></TD>
</TR>
</TABLE>
<BR>

<TABLE BORDER=&quot;0&quot; CELLSPACING=&quot;0&quot; CELLPADDING=&quot;0&quot; ALIGN=&quot;center&quot; WIDTH=&quot;600&quot;>
<TR BGCOLOR=&quot;navy&quot;>
<TD WIDTH=&quot;5&quot;></TD>
<TH ALIGN=&quot;left&quot; HEIGHT=&quot;24&quot; WIDTH=&quot;60&quot;><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot; COLOR=&quot;white&quot;> FName</FONT></TH>
<TH ALIGN=&quot;left&quot; HEIGHT=&quot;24&quot; WIDTH=&quot;50&quot;><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot; COLOR=&quot;white&quot;> LName</FONT></TH>
<TH ALIGN=&quot;left&quot; HEIGHT=&quot;24&quot; WIDTH=&quot;200&quot;><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot; COLOR=&quot;white&quot;> Address</FONT></TH>
<TH ALIGN=&quot;left&quot; HEIGHT=&quot;24&quot; WIDTH=&quot;80&quot;><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot; COLOR=&quot;white&quot;> City</FONT></TH>
<TH ALIGN=&quot;left&quot; HEIGHT=&quot;24&quot; WIDTH=&quot;120&quot;><FONT FACE=&quot;Arial, Helvetica&quot; SIZE=&quot;2&quot; COLOR=&quot;white&quot;> Phone</FONT></TH>
</TR>
<CFOUTPUT>
<cfif IsDefined(&quot;form.FName&quot;)>
<TR BGCOLOR=&quot;lightgrey&quot; HEIGHT=&quot;24&quot;>
<TD WIDTH=&quot;5&quot; HEIGHT=&quot;24&quot;><IMG height=3 src=&quot;Images/hspacer3.gif&quot; width=3></TD>
<TD>#form.Fname#</TD>
<TD>#form.LName#</TD>
<TD>#form.Address#</TD>
<TD>#form.City#</TD>
<TD>#form.Phone#</TD>
<TD><INPUT TYPE=&quot;checkbox&quot; VALUE=&quot;&quot;></TD>
<TD><INPUT TYPE=&quot;checkbox&quot; VALUE=&quot;&quot;></TD>
<CFELSE>
</CFIF>
</TR>
</TABLE>
<BR>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Return&quot; onClick=&quot;window.location='../SubD/Dsp_Project_PickBox.cfm'&quot;>
<INPUT TYPE=&quot;Reset&quot; VALUE=&quot;Cancel&quot;>
</FORM>
<BR>
</CFOUTPUT>

 
The only problem I see with the hidden form field is that it's located inside of the select form field.

Try closing the multi-select first:

</SELECT>
<input TYPE=&quot;Hidden&quot; NAME=&quot;list2&quot; VALUE=&quot;#newlist#&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top