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

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
gregoryrsmithAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrichmonCommented:
I am confused.  Why do you think it is not a number?
0
pinaldaveCommented:
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
gregoryrsmithAuthor Commented:
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
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

pinaldaveCommented:
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
gregoryrsmithAuthor Commented:
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
mrichmonCommented:
<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
mrichmonCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.