View Single Post
  #1  
Old 12th September 2009, 08:37
Edgein's Avatar
Edgein Edgein is offline
Senior Member
 
Join Date: Sep 2008
Netherlands
Posts: 154
Smile [FTS 1.1] Ajax Poller
Because i can get the normal poll working i made an another poll working en it looks even better

Click the image to open in full size.

1 st

upload the files in to the good folder

the files in the folder clientside you can over write them

  1. Modify dbConnect.php. into the include folder Insert your dbName, username and password. You may have to create a new database.
  2. Edit createDbTables.php. Insert your dbName, username and password and execute the script in your web browser
after creating the db tabels you can delete the fale createDbTables.php

in the admin folder is the polladmin.php this file is fore maken a new poll you can edit the staff tools and put het into the staff panel

now the index.php

detete

PHP Code:
ffactory::pollwatch(); 
PHP Code:
$pollindex
and replace

PHP Code:
if($pollindex == 'yes') {
echo 
_br;
    
FFactory::pollshow();

with

PHP Code:
?>

<table width=100% class=none border=0 cellspacing=0 cellpadding=0><tr><td class=embedded>
<h2>Poll</h2>
<br>
    <link rel="stylesheet" href="css/ajax-poller.css" type="text/css">
    <script type="text/javascript" src="js/ajax.js"></script>
    <script type="text/javascript" src="js/ajax-poller.js">    </script>


 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return false" method="post">
        <?php
                $res 
mysql_query("select * from poller ORDER by ID DESC LIMIT 1");
        if (
mysql_num_rows($res)) 
        
$inf mysql_fetch_array($res);
        
$pollerId = (int)$inf['ID'];
                
?>
                <!-- START OF POLLER -->
                <div class="poller">
                
                        <div class="poller_question" id="poller_question<? echo $pollerId?>">
                        <?php                   
                        
// Retreving poll from database
                        
$res mysql_query("select * from poller where ID='$pollerId'");        
                        if(
$inf mysql_fetch_assoc($res)){
                                echo 
"<p class=\"pollerTitle\">".$inf["pollerTitle"]."</p>";    // Output poller title
                                
                                
$resOptions mysql_query("select * from poller_option where pollerID='$pollerId' order by pollerOrder") or die(mysql_error()); // Find poll options, i.e. radio buttons
                                
while($infOptions mysql_fetch_array($resOptions)){
                                        if(
$infOptions["defaultChecked"])$checked=" checked"; else $checked "";
                                        echo 
"<p class=\"pollerOption\"><input$checked type=\"radio\" value=\"".$infOptions["ID"]."\" name=\"vote[".$inf["ID"]."]\" id=\"pollerOption".$infOptions["ID"]."\"><label for=\"pollerOption".$infOptions["ID"]."\" id=\"optionLabel".$infOptions["ID"]."\">".$infOptions["optionText"]."</label></p>";       
                        
                                }
                        }                       
                        
?>                      
                        <a href="#polls" onclick="castMyVote(<? echo $pollerId?>,document.forms[1])"><img src="pic/vote_button.gif"></a><a name="polls"></a>
                        </div>
                        <div class="poller_waitMessage" id="poller_waitMessage<? echo $pollerId?>">
                                Getting poll results. Please wait...
                        </div>
                        <div class="poller_results" id="poller_results<? echo $pollerId?>">
                        <!-- This div will be filled from Ajax, so leave it empty -->
                        </div>
                </div>
                <!-- END OF POLLER -->
                <script type="text/javascript">
                //if(useCookiesToRememberCastedVotes){
                        var cookieValue = Poller_Get_Cookie('dhtmlgoodies_poller_<? echo $pollerId?>');
                        if(cookieValue && cookieValue.length>0)displayResultsWithoutVoting(<? echo $pollerId?>); // This is the code you can use to prevent someone from casting a vote. You should check on cookie or ip address
                
                //}
                </script>
</form>
<?
my index.php is into the rar file

good luck with it

grtzz edgein
Attached Files
File Type: rar ajax poller.rar (17.7 KB, 45 views)
Reply With Quote
The Following User Says Thank You to Edgein For This Useful Post:
Phogo (13th September 2009)