Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > HTML / XHTML
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 09-15-2008, 06:00 PM
  #1
skeezy keyz
Novice (Level 1)
 
Join Date: Sep 2008
Posts: 3
iTrader: (0)
skeezy keyz is an unknown quantity at this point
How to make a "vote" button?

Hello,

New to the forum. I was wondering how I could make a "vote" type feature on my site... for example:

Which do you prefer: Apples or Bananas?

(radio button) Apples
(radio button) Bananas

submit vote





Thank you
skeezy keyz is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 10:58 AM
  #2
skeezy keyz
Novice (Level 1)
 
Join Date: Sep 2008
Posts: 3
iTrader: (0)
skeezy keyz is an unknown quantity at this point
bumpy bump
skeezy keyz is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-17-2008, 05:13 PM
  #3
skateme
Champion (Level 13)
 
Join Date: Feb 2007
Location: MD
Posts: 219
iTrader: (0)
skateme is on a distinguished road
You'll need to make a handler to process the form, preferable in PHP, as its easier than most of the other languages.

The code for the radio buttons is

Code:
<form name="vote" action="handler.php" method="post">
<p><input type="radio" id="apple" name="apple" />Apples</p>
<p><input type="radio" id="bananas" name="bananas" />Bananas</p>
<input type="submit" value="Submit" />
</form>
The PHP handler might be:
Code:
<?php
$vote = $_REQUEST['vote'];
if ($vote == 'apple') {
echo "You voted apple";
}
else {
echo "You voted banana";
}

?>
Just a quick write up, let me know if there are any problems
__________________
4+ years of experience with XHTML, HTML, CSS, PHP, and more. Need help? Contact me.
skateme is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 02:37 PM
  #4
skeezy keyz
Novice (Level 1)
 
Join Date: Sep 2008
Posts: 3
iTrader: (0)
skeezy keyz is an unknown quantity at this point
skateme thank you! the code works great it comes out and everything. so I guess this is going into php stuff. so do I need scripting to gather the data then?

basically after a vote is cast how do I see the results (or even make a page that makes the results public)?
skeezy keyz is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 04:20 PM
  #5
skateme
Champion (Level 13)
 
Join Date: Feb 2007
Location: MD
Posts: 219
iTrader: (0)
skateme is on a distinguished road
In order to do that you'll have to add each vote to a database like MySQL to store the votes. I'm not really great with PHP or MySQL so I cannot help you on this. I suggest you get help from the people at phpfreakz.com or just learn PHP as its a feature-rich language that will do nothing but benefit you in the long run and your web site. Good luck!

Comments on this post
matthewm27 agrees: Thanks
__________________
4+ years of experience with XHTML, HTML, CSS, PHP, and more. Need help? Contact me.
skateme is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 04:22 PM
  #6
althalus
For science, you monster
 
althalus's Avatar
 
Join Date: Jan 2004
Location: Inferno - 7th Circle, Inner Ring
Posts: 3,588
iTrader: (1)
althalus is a glorious beacon of lightalthalus is a glorious beacon of lightalthalus is a glorious beacon of lightalthalus is a glorious beacon of lightalthalus is a glorious beacon of light
Quote:
Originally Posted by skateme View Post
I suggest you get help from the people at htmlforums.com
Your post had an error. I fixed it for you.






(This forum is full of PHP coders, why go elsewhere?)

Comments on this post
matthewm27 agrees: LOL, I was about to post somthing like that.
__________________

░░░░░[blogtwitter] ░░░░░the perpetual journey to next autumn~
althalus is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 04:47 PM
  #7
matthewm27
SuperHero (Level 14)
 
Join Date: Jul 2008
Location: P.A.
Posts: 286
iTrader: (0)
matthewm27 is on a distinguished road
IDK if this will work, but i figured since im sorta good at javascript, i might be able to figure somthing out in php:

PHP Code:
<?php
$vote 
$_REQUEST['vote'];
echo 
"You voted " $vote;

?>
OR

PHP Code:
<?php
$vote 
$_REQUEST['vote'];
echo 
"You voted $vote";

?>
Can someone tell me if that would work, because that is the first time i have ever wrote php!
matthewm27 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 08:43 PM
  #8
skateme
Champion (Level 13)
 
Join Date: Feb 2007
Location: MD
Posts: 219
iTrader: (0)
skateme is on a distinguished road
lol Yes that'll work. You should definitely try to master PHP. I'm sure you'll do great. I was really into PHP/MySQL a couple months ago but my desire to learn Cocoa and Applescript overwhelmed me so PHP was left in the dust. Cocoa hasn't been going so great so I'll probably go back into PHP soon..
__________________
4+ years of experience with XHTML, HTML, CSS, PHP, and more. Need help? Contact me.
skateme is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 09:48 PM
  #9
matthewm27
SuperHero (Level 14)
 
Join Date: Jul 2008
Location: P.A.
Posts: 286
iTrader: (0)
matthewm27 is on a distinguished road
Talking

YAY

Never heard of Cocoa or Applescript.

Will both of them work, or just one, if so, which.
matthewm27 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2008, 09:54 PM
  #10
matthewm27
SuperHero (Level 14)
 
Join Date: Jul 2008
Location: P.A.
Posts: 286
iTrader: (0)
matthewm27 is on a distinguished road
Quote:
Comments on this post

matthewm27 agrees: Thanks
Sorry, I gave Comments on the wrong post
matthewm27 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-20-2008, 08:23 AM
  #11
skateme
Champion (Level 13)
 
Join Date: Feb 2007
Location: MD
Posts: 219
iTrader: (0)
skateme is on a distinguished road
The second one will definitely work. I'm not sure about the first one, but I'm 99% sure it won't work. PHP allows you to use variables in the echo command if they are enclosed in quotation marks ("). If they are only in quotes ('), then variables can't be used, only plain text.

Btw, Cocoa and Applescript are programming languages for Mac. Applescript is written like you're speaking in English (tell application "Photoshop"...) while Cocoa is more progammy. It's based on Objective-C.
__________________
4+ years of experience with XHTML, HTML, CSS, PHP, and more. Need help? Contact me.
skateme is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-20-2008, 09:09 AM
  #12
matthewm27
SuperHero (Level 14)
 
Join Date: Jul 2008
Location: P.A.
Posts: 286
iTrader: (0)
matthewm27 is on a distinguished road
Okay, well i'm happy. Thanks.

I had a gut feeling that Applescript had something to do with Apple. Although, knowing Apple, I figured it would be called something like "I-Script."
matthewm27 is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply
KEEP TABS
SPONSORS
 
Boxedart

 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  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
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 05:52 PM.

   

Mascot team created by Drawshop.com | Web Hosting

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.