Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old March 21st, 2004, 02:14 PM
beeman81 beeman81 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Jakobstad, Finland
Posts: 59 beeman81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
checkboxes in mailform

Ok, so I got the textfileds working on my mailform just fine, but I can´t find any info on checkboxes.

Lets say I want a checkbox named toiletpaper (best I could think of at the moment) in my mailform... How would the php code look like?

...So when I get the mail sent to me, it would say: toiletpaper: yes

Reply With Quote
  #2  
Old March 21st, 2004, 03:32 PM
honcho's Avatar
honcho honcho is offline
Contributing User
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Cape Cod
Posts: 1,347 honcho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 2 sec
Reputation Power: 3
RE: checkboxes in mailform

Checkboxes only take values if they are checked, so you have to do things a little different than textfields. Here's how I would do it:

In your HTML form:
Code:
<input type="checkbox" value="Y" id="toiletpaper"> Toilet paper?


In your PHP code (assuming you are using POST in your form):
php Code:
Original - php Code
  1.  
  2. if(isset($_POST['toiletpaper']) AND $_POST['toiletpaper'] == 'Y')
  3. {
  4.     $email_body .= "toiletpaper: yesn";
  5. } else {
  6.     $email_body .= "toiletpaper: non";
  7. }

Reply With Quote
  #3  
Old March 21st, 2004, 03:39 PM
nazly nazly is offline
Codewalkers Beginner (1000 - 1499 posts)
 
Join Date: Apr 2007
Location: Colombo,SriLanka
Posts: 1,325 nazly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 18 sec
Reputation Power: 3
Send a message via Yahoo to nazly
RE: checkboxes in mailform

Better read this FAQ
http://codewalkers.com/faq/2/29.html

Thats how I would do it..
In HTML page name it in this fashion

<input type="checkbox" name="mycheck[toiletpaper]" value="Y">
<input type="checkbox" name="mycheck[oilpaper]" value="Y">
<input type="checkbox" name="mycheck[somepaper]" value="Y">

In PHP

php Code:
Original - php Code
  1.  
  2. $myCheck=$_POST["mycheck"];
  3. foreach($hobby as $key=>$value){
  4.  if($value=="Y")echo $key." : yes<br>";
  5. }


I hope it makes sense..

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > checkboxes in mailform


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway