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

Problem with Pound sign (#) in CFML expression...pls help me

Status
Not open for further replies.

accuransx

Programmer
Sep 23, 2000
62
MY
I want to make a loop for a running count no for my dynamic variables like Name1, Name2 and Name3. Those numbers which are 1, 2 and 3 in my variables name is from my running count no:

<cfloop index=&quot;x&quot; from=&quot;1&quot;='#Session.SPeribadi_Spouse_no#' step=&quot;1&quot;>
<CFSET Session.SPeribadi#x#_Age='#form.Pasangan#x#_Age#'>

My problem is whenever i used my variable more than once in an expression ( i can not use CFSET to set using my dynamic variable), an parser error occured.

How can i write this expression with no syntax errors?
[sig][/sig]
 
You might try:

<cfloop index=&quot;x&quot; from=&quot;1&quot; TO=&quot;#evaluate(Session.SPeribadi_Spouse_no)#&quot; step=&quot;1&quot;>
<CFSET Session.SPeribadi#x#_Age='#form.Pasangan#x#_Age#'>
</CFLOOP>

webron [sig][/sig]
 
No...its not working...my problem is to loop to generate dynamic var like Name1, name2, Name3 where their format is Name#x#

But when i want to CFSET like:

<cfloop index=&quot;x&quot; from=&quot;1&quot; TO=&quot;#evaluate(Session.SPeribadi_Spouse_no)#&quot; step=&quot;1&quot;>

<CFSET Session.SName#x# = '#form.Name#x#'>

</cfloop>

Error Diagnostic Information
Just in time compilation error

Invalid parser construct found on line 4 at position 21. ColdFusion was looking at the following text:

#
Invalid expression format. The usual cause is an error in the expression structure.
The last successfully parsed CFML construct was a CFSET tag occupying document position (4:1) to (4:6).

The specific sequence of files included or processed is:
D:\TestFiles\loop2\set.cfm


Date/Time: 09/24/00 13:48:36
Browser: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)
Remote Address: 192.168.0.5
HTTP Referer:
[sig][/sig]
 
Hi guys!

<cfloop index=&quot;x&quot; from=&quot;1&quot; TO=&quot;#evaluate(Session.SPeribadi_Spouse_no)#&quot; step=&quot;1&quot;>
[tab]<CFSET Session.SName#x# = '#form.Name#x#'>
</cfloop>

you cant do that the cfml parser will call for an error
but you can do that:

<cfloop index=&quot;x&quot; from=&quot;1&quot; TO=&quot;#evaluate(Session.SPeribadi_Spouse_no)#&quot; step=&quot;1&quot;>
[tab]<CFSET temp = SetVariable(&quot;Session.SName#x#&quot;,&quot;#form.Name#x#&quot;)>
</cfloop>

This will work perfectly,
have fun,
Chris
[sig][/sig]
 
Ok, it's working in most cases (for a variable set), but if I want to do the following thing in a loop:

<CFIF 'Form.thema_#i#' IS &quot;yes&quot;>theme_name_#i#<br></CFIF>
how can i do ?

 
To check the value of a dynamic variable, you'll have to use the evaluate() function. For your example, it would be <CFIF evaluate(&quot;#Form.thema_##i#&quot;) IS &quot;yes&quot;>theme_name_#i#<br></CFIF> assuming your form variable is called &quot;thema_&quot; and &quot;i&quot; is another variable.

I think that will do it but let me know if you have any problems.
GJ
 
it sounds great .. but still doesn't work :-(

>>Error Diagnostic Information
>>An error occurred while evaluating the expression:
>> evaluate(&quot;#Form.thema_##i#&quot;) is &quot;yes&quot;

I can send u the complete code if you want, just give me your email adress

thanks

Olivier
 
Try :
evaluate(&quot;Form.thema_#i#&quot;) is &quot;yes&quot;

 
I think the problem now omes from the fact that when u dont check a box, the value isn't sent to the 2nd page.

I tried to use a defalut parameter

<cfparam name=&quot;thema_#i#&quot; default=&quot;no&quot;>
just before the
<cfinput type=&quot;checkbox&quot; name=&quot;thema_#i#&quot; VALUE=&quot;yes&quot;>#type_thematique#<br>

but it doesnt seem to work ...



 
It is normal that it doesn't work.
Your :
<cfparam name=&quot;thema_#i#&quot; default=&quot;no&quot;>
is Coldfusion : server side. Changes nothing to your input box : client side.

But it is a good idea. The cfparam should just be used at the right place: In your action page.

Of course it becomes :
<cfparam name=&quot;form.thema_#i#&quot; default=&quot;no&quot;>


 
TADA

it's now working ... thanks a lot, i was just about to build the checkboxes in pure HTML, static ...

I'm now having troubles with the SQL request, with the AND, OR, using the results of the checkbowes... but i'm working on it, so i will ask for help only if i still have troubles after a few hours...

thanks again for help

Olivier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top