• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

loop

Guest
Mar 08, 2007 Mar 08, 2007

Copy link to clipboard

Copied

Hi i have 5 text boxes which are named phone1, phone2 etc

i need to run a loop through the code below to do the following

1. evaluate to see if the form elements are empty
2. if not empty get rid of spaces and leading zero
3. once that is done loop through this code.

i have this code to get rid of spaces and leading zero but how do add this to a loop for each text box?

<cfif left(form.Phone1,1) EQ "0">
<cfset PhoneNo =removeChars(replace(form.Phone1, " ", "", "all"),1,1)><cfelse>
<cfset PhoneNo =form.Phone1>
</cfif>
TOPICS
Advanced techniques

Views

397

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 11, 2007 Mar 11, 2007
It only takes a minor addition to the code, thus

Votes

Translate

Translate
Guest
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Your text box names are phone1, phone2, phone3, phone4 and phone5, right? Then the code below should get you started. The secret is to dynamically generate each phone variable.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 10, 2007 Mar 10, 2007

Copy link to clipboard

Copied

Hi jdeline

i have tried that but get an error of
Variable PHONE is undefined.

<CFLOOP INDEX="k" FROM="1" TO="5">
<CFSET foo = phone & k>
<CFIF foo IS NOT "">

any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

You might want to play around with this. The result of interest is formStruct. I have included an example.



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2007 Mar 10, 2007

Copy link to clipboard

Copied

typo: "phone"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 10, 2007 Mar 10, 2007

Copy link to clipboard

Copied

ok i am now using your version, i have a cfmail which i need inside the loop but the variable do i need to email each phone1, phone 2 etc

ie

<cfmail
to = "emai"
from = "email"
subject = "test">

#formStruct#

</cfmail>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 10, 2007 Mar 10, 2007

Copy link to clipboard

Copied

The (edited) example says it.

whether or not form field phone3 was empty: formStruct.phone3.isFilled
number entered (that is, form.phone3): formStruct.phone3.number

<cfmail
to = "email"
from = "email"
subject = "test">

Hi #firstName#,

<cfif formStruct.phone3.isFilled>
Thanks for sending us your phone number. To confirm, your GSM number is #formStruct.phone3.number#.
<cfelse>
Please send us your GSM number so that we can inform you of new offers.
</cfif>

</cfmail>


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

ok i have tried that but get an error

Element PHONE3.NUMBER is undefined in FORMSTRUCT

what i need is if 4 of the 5 text boxes (phone1,2,3,4,5) are not empty send a email 4 times with the different phone number in each

do i need to have 5 different cfmails?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 11, 2007 Mar 11, 2007

Copy link to clipboard

Copied

LATEST
It only takes a minor addition to the code, thus

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation