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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing the rest of the words 1

Status
Not open for further replies.

IFELSETHEN

Programmer
May 1, 2002
221
0
0
US
Hi to all ….
I have a select list that I populate from a record set. I allow multiple selects. The form is sent to a processing template. The items on the select form can be more then one words. Like: Green Cars. The problem is when I evaluate the FieldName(s) that are sent I only get Green not Green Cars. Here's the code.

************ SELECT CODE **************************
<select name=fieldFrom size=5 style=&quot;width:120;&quot; multiple>
<cfif qdetail.RecordCount gt 0>
<cfoutput query=&quot;qdetail&quot;>
<!--- load list box with all. --->
<option value =#qDetail.pref_detail#>#qDetail.pref_detail#</option>
</cfoutput>
</cfif>
</select>
************* GET CODE **************************
<CFLOOP Index=&quot;FieldName&quot; List=&quot;#Form.Fieldnames#&quot; DELIMITERS=&quot;,&quot;>
<tr><td>#FieldName#</td> <td>#Evaluate(FieldName)#&nbsp;</td></tr>
<cfif #FieldName# eq 'FIELDFROM'>
<cfif loop_flag eq 0>
<cfset loop_flag = 1>
<cfset ary_from = ListToArray(Evaluate(FieldName))>
</cfif>
</cfif>
<cfif #trim(FieldName)# eq 'EDIT_TO'>
<cfset edit_to2 = #Evaluate(FieldName)#>
</cfif>
</CFLOOP>

As you can see I am using ListToArray to parse the selected items coming from the form.

Thanks for the help ..... John

*********************
John Nyhart
*********************
 
had the same problem.....

just change this....
<select name=fieldFrom size=5 style=&quot;width:120;&quot; multiple>
<cfif qdetail.RecordCount gt 0>
<cfoutput query=&quot;qdetail&quot;>
<!--- load list box with all. --->
<option value =&quot;#qDetail.pref_detail#&quot;>#qDetail.pref_detail#</option>
</cfoutput>
</cfif>
</select>

grtfercho çB^]\..
&quot;Imagination is more important than Knowledge&quot; A. Einstein
 
Hmmmm... I tried to replicate this with the following:

Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
	<title>Untitled</title>
</head>

<body>
<CFIF IsDefined(&quot;FORM.fieldFrom&quot;)>
	<CFSET loop_flag = 0>
	<CFLOOP Index=&quot;FieldName&quot; List=&quot;#Form.Fieldnames#&quot; DELIMITERS=&quot;,&quot;>
	    <CFOUTPUT><tr><td>#FieldName#</td> <td>#Evaluate(FieldName)# </td></tr> </CFOUTPUT>
	        <cfif #FieldName# eq 'FIELDFROM'>
	            <cfif loop_flag eq 0>
	                <cfset loop_flag = 1>
	                <cfset ary_from = ListToArray(Evaluate(FieldName))>
	            </cfif>
	        </cfif>
	        <cfif #trim(FieldName)# eq 'EDIT_TO'>
	            <cfset edit_to2 = #Evaluate(FieldName)#>
	        </cfif>
	</CFLOOP>
	<CFDUMP var=&quot;#ary_from#&quot;>
</CFIF>

<CFSCRIPT>
	qdetail = QueryNew(&quot;pref_detail&quot;);
	
	QueryAddRow(qdetail,5);
	
	QuerySetCell(qdetail,&quot;pref_detail&quot;,&quot;Green Cars&quot;, 1);
	QuerySetCell(qdetail,&quot;pref_detail&quot;,&quot;Red Cars&quot;, 2);
	QuerySetCell(qdetail,&quot;pref_detail&quot;,&quot;White Cars&quot;, 3);
	QuerySetCell(qdetail,&quot;pref_detail&quot;,&quot;Yellow Cars&quot;, 4);
	QuerySetCell(qdetail,&quot;pref_detail&quot;,&quot;Purple Cars&quot;, 5);

</CFSCRIPT>

<CFOUTPUT><form action=&quot;#GetFileFromPath(GetBaseTemplatePath())#&quot; method=&quot;post&quot; name=&quot;formname&quot; id=&quot;formname&quot;></CFOUTPUT>
<select name=fieldFrom size=5 style=&quot;width:120;&quot; multiple>
<cfif qdetail.RecordCount gt 0>
        <cfoutput query=&quot;qdetail&quot;>
            <!--- load list box with all. --->
        <option value=&quot;#qDetail.pref_detail#&quot;>#qDetail.pref_detail#</option>
        </cfoutput>    
    </cfif> 
</select>
<br />
<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;>
</form>

</body>
</html>

and all values come out as expected (&quot;Green Cars&quot;, &quot;Yellow Cars&quot;, etc).

Are you sure the qDetail.pref_detail field in your data contains the whole string?



-Carl
 
Ahhh... got it.

You need quotes in your option tag:

Code:
<option value =&quot;#qDetail.pref_detail#&quot;> ...

otherwise the browser understands it as:
Code:
<option value=Green Cars>
where &quot;Green&quot; is the value of the value attribute, and &quot;Cars&quot;, it thinks, is another attribute.



-Carl
 
Carl .... your the man of the hours ..... thanks to both of you for the help ..... it now works.
John


*********************
John Nyhart
*********************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top