[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

converting string to number tried val(), int() and_integer as suffix

Posted on 2004-11-05
7
Medium Priority
?
17,536 Views
Last Modified: 2013-12-24
Hi,

Is there any way to convert a form value to a number?

I've tried <cfoutput>#Val(FORM.numOfFields)#</cfoutput>
             <cfoutput>#Int(FORM.numOfFields)#</cfoutput>
and CF said that naming the input with a  _integer  suffix would make CF automatically convert string to number, but I got the same error.

Thanks for any help,
Greg
0
Comment
Question by:gregoryrsmith
  • 3
  • 2
  • 2
7 Comments
 
LVL 35

Expert Comment

by:mrichmon
ID: 12509567
I am confused.  Why do you think it is not a number?
0
 
LVL 21

Expert Comment

by:pinaldave
ID: 12509630
Hi gregoryrsmith,
val() and int() functions if there is no number but only text in the field of numoffileds then it will give you NULL and will not display anything.

Regards,
---Pinal
0
 

Author Comment

by:gregoryrsmith
ID: 12509655
The error says this

The value "<cfoutput>3</cfoutput>" cannot be converted to a number

I went to the documentation and searched Google and this site, but the 3 things I've tried (above) still produced the above error.

0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
LVL 21

Expert Comment

by:pinaldave
ID: 12509667
Hi gregoryrsmith,
 '<cfoutput>3</cfoutput>'
your form value is sending this information...that is incorrect. Check yoru form value...
may be in yoru form where you are submitting the value is like that... value='<cfoutput>numOfFields</cfoutput>'
which is not correct "may be" ...so just check yoru form again.


Regards,
---Pinal
0
 

Author Comment

by:gregoryrsmith
ID: 12509934
Checked it, maybe you see something I don't (very likely)?

<cfoutput>
  <form action="c_UplThumb.cfm" method="post">
    <input name="numOfFields" type="text" size="5" maxlength="5"><br>
      <input name="folderNumber" type="hidden" value="#FORM.number#">
    <input type="submit" name="Submit" value="OK">
  </form>       
      </cfoutput>

The action page here

<form action="c_UplThumb2.cfm" method="post" enctype="multipart/form-data">
     <cfloop index="i" from="1" to="<cfoutput>FORM.numOfFields#</cfoutput>" step="1">
      <cfset filename = "file" & #i#>
       <input type="File" name="<cfoutput>#variables.filename#</cfoutput>"><br>
      </cfloop>
         <input type="hidden" name="finalFolder"
               value="<cfoutput>#FORM.folderNumber#</cfoutput>

              <input type="Submit" name="upload" value="upload">
 </form>

Thanks,
G
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 12510099
<cfloop index="i" from="1" to="<cfoutput>FORM.numOfFields#</cfoutput>" step="1">
on the action page is incorrect.

SHould be:

<cfloop index="i" from="1" to="#FORM.numOfFields#" step="1">

NO CFOUTPUT inside the cfloop tag
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 1000 total points
ID: 12510106
In general you never need cfoutput inside cold fusion tags

Additionally you don't need # signs UNLESS it is inside a quoted string (such as in the case of cfloop)
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
What You Need to Know when Searching for a Webhost Provider
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline

868 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