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

I need some guidance

New Here ,
Jan 28, 2009 Jan 28, 2009
I hope I can explain this...
Envision a screen that shows the name of each person that is a member in a club. Next to each person is a checkbox. I want other users to be able to place a check in the box next to one/some/all members. Once the submit button is clicked, a variable could be created with the value of each e-mail address added (cfloop) - this variable could then be used as the "mailto" to open the users e-mail client and create an e-mail to send to any user that was checked.

I'm not sure how to name the checkbox to be unique so that the correct e-mail address get passed.

I originally did this with cfmail - and just looped through and created an e-mail (using a form for the e-mail text itself) and sent it out, but now I'm finding most of the e-mails are being stopped as my host server thinks it is spam.

I can't most the code that I have created as it is propriatary - any help is greatly appreciated
1.1K
Translate
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

Engaged , Jan 29, 2009 Jan 29, 2009
Hi again. I am attaching the code again but this time with comments. It might make it a bit easier to understand.

Good luck.

Make sure you do try the code out on your CF server and give it a go adding your own checkboxes etc.

Thanks,
Mikey.
Translate
LEGEND ,
Jan 28, 2009 Jan 28, 2009
Give them all the same name. Submit your form, do <cfdump var="#form#"> and see what you get.

Then do it again without checking any boxes.

If you have any trouble interpreting what you see, ask.
Translate
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
Explorer ,
Jan 28, 2009 Jan 28, 2009
Line Dan said, name all the checkbox fields the same. The value for each one should be the email address of the person for whom the checkbox represents.

When the form is submitted, the value of the field will be a comma-delimited list of all the email addresses, and you can just use that form value in the TO attribute of your CFMAIL tag.

Now, if none of the checkboxes were checked, the form field will not exist on the form action page, so either do an IsDefined check or set a default value. Either way, you don't want to send the message to no addresses, you'll get an error.

Good luck!
Translate
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
New Here ,
Jan 29, 2009 Jan 29, 2009
I'm just not getting anywhere... I get the error: variable sendEmail is undefined

here is the code...
Translate
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
Explorer ,
Jan 29, 2009 Jan 29, 2009
The variable sendEmail won't exist on your form action page, because it appears to the the name of your form, not of any field in the form. The variable to use on the form action page is FORM.memberMail as that is the name of your checkbox field. But remember, if none of the boxes or checked, that variable won't exist.

It also looks like you need to use # signs around the value of memberMail field. u.emailAddress seems to be the name of a variable as opposed to an actual email address.
Translate
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
New Here ,
Jan 29, 2009 Jan 29, 2009
I still get - "Element MEMBERMAIL is undefined in FORM"

I appreciate your time in trying to help me

Translate
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
Explorer ,
Jan 29, 2009 Jan 29, 2009
That variable won't exist if none of the boxes are checked. That's where either CFPARAM or IsDefined would come into play.
Translate
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
New Here ,
Jan 29, 2009 Jan 29, 2009
but I checked three of the boxes to make my first test - I will code for no boxes selected later.
Translate
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
Explorer ,
Jan 29, 2009 Jan 29, 2009
I'm not sure about cfform, but I know on HTML forms the default method is "get" as opposed to "post". In that case, no form variables would exist, they would all be url variables. You might want to add method="post" to your cfform tag to see if that helps.
Translate
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
Engaged ,
Jan 29, 2009 Jan 29, 2009
It's quite clear you are confused how checkboxes and forms work. This is considered basic CF.

I have written a little demo for you. Please have a look at the code and have a go at putting it into a test page to see it working. It will give you a better understanding of how this works.



<cfif isDefined("form.submitBtn")>

<cfif isDefined("form.myCheckbox")>
<h3>Here are the selected checkboxes.</h3>
<p>The checkboxes NOT checked are not passed in, only the ones checked are.</p>
<p>The selected checkboxes are all laid out in a comma seperated list.</p>
<p>This makes it easy to loop and do stuff with it.</p>

<h4>Here is a CFDUMP</h4>
<cfdump var="#form.myCheckbox#" />

<h4>Here is a CFLOOP of the checkboxes.</h4>

<cfoutput>
<ul>
<cfloop index="i" list="#form.myCheckbox#" delimiters=",">
<li>#i#</li>
</cfloop>
</ul>
</cfoutput>

<cfelse>
<h3>Nothing was selected!</h3>
</cfif>

</cfif>

<form action="<cfoutput>#cgi.script_name#</cfoutput>" method="post">

<div>
<label>Checkbox 1</label>
<input type="checkbox" name="myCheckbox" value="email@hmm.com" />
</div>

<div>
<label>Checkbox 2</label>
<input type="checkbox" name="myCheckbox" value="ooo@hmm.com" />
</div>

<div>
<label>Checkbox 3</label>
<input type="checkbox" name="myCheckbox" value="sfsdfsf@hmm.com" />
</div>

<div>
<label>Checkbox 4</label>
<input type="checkbox" name="myCheckbox" value="sdfsdf@hmm.com" />
</div>

<div>
<label>Checkbox 5</label>
<input type="checkbox" name="myCheckbox" value="ewrrw@hmm.com" />
</div>

<div>
<input type="submit" name="submitBtn" value="Submit Checkboxes" />
</div>

</form>

Try that code above out and see if that helps. All you need to do then is apply these concepts to your own application.

Good luck,
Mikey.
Translate
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
LEGEND ,
Jan 29, 2009 Jan 29, 2009
TA-Selene wrote:
> I'm not sure about cfform, but I know on HTML forms the default method is "get"
> as opposed to "post".

That is true for <cfform...> as well. Since ultimatly all <cfform...> is
is a wizzard that will build an HTML <form...> with associated
JavaScript for my advanced validation and DHTML purpose
Translate
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
New Here ,
Jan 29, 2009 Jan 29, 2009
Thanks Kapitaine (any you too TA-Selene), I really appreciate your help. I've been away from CF for a year and have forgotten much.

Kapitaine - I will take a good look at your code and see what I can do. Again, thanks for your help.
Translate
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
Engaged ,
Jan 29, 2009 Jan 29, 2009
Hi again. I am attaching the code again but this time with comments. It might make it a bit easier to understand.

Good luck.

Make sure you do try the code out on your CF server and give it a go adding your own checkboxes etc.

Thanks,
Mikey.
Translate
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
New Here ,
Jan 29, 2009 Jan 29, 2009
LATEST
My code is now up and working - THANK YOU!

I will save your code for the next time I forget 😉
Translate
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