Jump to content


Photo

How do i get checkboxes to email?


  • Please log in to reply
4 replies to this topic

#1 JohneeMac

JohneeMac
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 19 March 2006 - 06:51 PM

Hi there.

How do i get checkbox values sent to my email account?

I have other variables that send fine like name, email etc and the mail () function works fine.

I would like to get checkboxes working though.

I have 6 activities such as quad biking, off road driving etc and how can i send these names if selected to my email account?

Thanks for your time.

#2 aaronrb

aaronrb
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 19 March 2006 - 06:55 PM

[!--quoteo(post=356448:date=Mar 19 2006, 06:51 PM:name=JohneeMac)--][div class=\'quotetop\']QUOTE(JohneeMac @ Mar 19 2006, 06:51 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hi there.

How do i get checkbox values sent to my email account?

I have other variables that send fine like name, email etc and the mail () function works fine.

I would like to get checkboxes working though.

I have 6 activities such as quad biking, off road driving etc and how can i send these names if selected to my email account?

Thanks for your time.
[/quote]


This probs sounds really basic but do you have the values set fot the checkboxes?

#3 Spixxx

Spixxx
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 March 2006 - 07:09 PM

Unchecked checkboxes have the value off, and checked have the value on. You do not need to define any values in the actual <input type="checkbox" etc> tag.

In the $subject, or whatever use this:

if($checkbox_variable == "on"){
echo "Checkbox: Yes";}
else{
echo "Checkbox: No";
}

Or replace Yes/No with whatever the checkbox is concerning...

Hope it helps.

#4 JohneeMac

JohneeMac
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 19 March 2006 - 07:18 PM

Is there a cleaner method without all the "if" and "else" statements?

I currently have 6 options but might be expanding them.

Thanks for replies so far.

#5 Spixxx

Spixxx
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 19 March 2006 - 07:23 PM

No, but if there is only one option you care about ie wether the checkbox is checked, then echo Checkbox: Yes, but if it isnt checked, then dont display anything you could just do

if($checkbox_variable == "on"){
echo "Checkbox: Yes";}

...with no else statement

Thats about as short as it gets


Try it.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users