[Help]Editing Voting Script

Newbie Spellweaver
Joined
Aug 12, 2010
Messages
81
Reaction score
3
Hey ragezoners.

I've been trieing to edit the voting script to let ppl choose their own rewards for voting.

I used the scripts from this guy: http://forum.ragezone.com/f457/best-voting-script-will-find-647777/

I've made this:
vote.php
PHP:
		<script type="text/javascript" src="vote/js/jquery.js"></script>
		<script type="text/javascript" src="vote/js/vote.js"></script>
		
		<div id="et_vbutton" onclick="etLiteGetVoteDialog();" style="background-image: url('vote/images/votenow.png'); text-align: center; width: 250px; height: 150px; position: absolute; top: 0px; right: 20px; cursor: pointer;">
			
			<div id="et_vcharenter" style="background-color: #F8F8F8; margin: 10px auto; width: 200px; height: 140px; text-align: center; display: none;">
				
				Character Name:<br/>
				<input type="text" id="etCharField"/><br/>
				
               
				<br>Select Reward Item:<br>
                <select name="etItemField" id="etItemField">
					<option value="1">3x Amplification ES (S)     </option>
			    	<option value="2">2x Scroll of Resurrection</option>
					<option value="3">2x Scroll of Holy</option>
				</select>
                <input type="submit" id="etCharSubmit" onclick="etLiteDoVoteDialog();" value="Vote!"/>

And i got this in the config where which contains the items that get send:
inc.config.php
PHP:
$voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
$voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
$voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);
But if someone choses the amps they will get the holy scroll because it's the lowest thing on the list. So i have to let the script know that it has the sent the amp if someone choses the amp and the holy if they choose the holy.

Other stuff that i did change or could be used:
class.vote.php
PHP:
	public function sendItem( $etCharacter )
	{
		
		global $mssqlCharacterDBF;
		
		global $voteReward;
		
		$rewardId = $voteReward['itemId'];
		$rewardName = $voteReward['itemName'];
		$rewardAmount = $voteReward['itemAmount'];
		$etCharacter = $this->mssql_escape_string($etCharacter);
		$etItem = $this->mssql_escape_string($etItem);
and this:
vote.js file
var etVoteCharacter = escape(encodeURI(document.getElementById("etCharField").value));
var etVoteItem = escape(encodeURI(document.getElementById("etItemField").value));

I hope you guys can help me asap with this problem.

Thanks (:
 
Last edited:
W3Schools ?

Or you could try something like putting reward IDs Z(using option value='Remantis Laccotte') in a combobox and then in config.php:

Code:
if ( $rewardid == "Remantis Laccotte" ) {
	$voteReward = array("itemName" => "Remantis Laccotte", "itemId" => idkfrommyhead, "itemAmount" => 50);
}

Something like that could work. I haven't tried anything, but I think thats somewhat the thing you want.
 
W3Schools ?

Or you could try something like putting reward IDs Z(using option value='Remantis Laccotte') in a combobox and then in config.php:

Code:
if ( $rewardid == "Remantis Laccotte" ) {
	$voteReward = array("itemName" => "Remantis Laccotte", "itemId" => idkfrommyhead, "itemAmount" => 50);
}

Something like that could work. I haven't tried anything, but I think thats somewhat the thing you want.

Thanks for this but I got one question i see that it's a 'if' code but how can i let the script or javascript w.e know that the player that chose the remantis tab that it's a remantis laccotte?
 
Since the $voteReward info is taken from inc.config.php I think that you should edit it there.

And you can also do like:

vote.php:
Code:
                <br>Select Reward Item:<br>
                <select name="reward">
                    <option value="1">3x Amplification ES (S)     </option>
                    <option value="2">2x Scroll of Resurrection</option>
                    <option value="3">2x Scroll of Holy</option>
                </select> 
                <input type="text" id="etCharField"/><br/>
inc.config.php:
Code:
if ($reward == "1" ) {
	$voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($reward == "2" ) {
	$voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($reward == "3" ) {
	$voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}

You could try something like this aswell:

inc.config.php:
Code:
if ($_POST['reward'] == 1) {
	$voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($_POST['reward'] == 2) {
	$voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($_POST['reward'] == 3) {
	$voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}
You can mess around with it and it might work. Or ofcourse pay Caja :w00t:
 
Last edited:
Since the $voteReward info is taken from inc.config.php I think that you should edit it there.

And you can also do like:

vote.php:
Code:
                <br>Select Reward Item:<br>
                <select name="reward">
                    <option value="1">3x Amplification ES (S)     </option>
                    <option value="2">2x Scroll of Resurrection</option>
                    <option value="3">2x Scroll of Holy</option>
                </select> 
                <input type="text" id="etCharField"/><br/>
inc.config.php:
Code:
if ($reward == "1" ) {
	$voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($reward == "2" ) {
	$voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($reward == "3" ) {
	$voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}

You could try something like this aswell:

inc.config.php:
Code:
if ($_POST['reward'] == 1) {
	$voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($_POST['reward'] == 2) {
	$voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($_POST['reward'] == 3) {
	$voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}
You can mess around with it and it might work. Or ofcourse pay Caja :w00t:

I tried both of the methods. But it seems that the script doesn't send anything at all anymore =/. It doesn't give any errors though. I currently got this:
The vote script itself
PHP:
	{
		
		?>
		
		<script type="text/javascript" src="vote/js/jquery.js"></script>
		<script type="text/javascript" src="vote/js/vote.js"></script>
		
		<div id="et_vbutton" onclick="etLiteGetVoteDialog();" style="background-image: url('vote/images/votenow.png'); text-align: center; width: 250px; height: 150px; position: absolute; top: 0px; right: 20px; cursor: pointer;">
			
			<div id="et_vcharenter" style="background-color: #F8F8F8; margin: 10px auto; width: 200px; height: 140px; text-align: center; display: none;">
                
                <br/>Character Name:<br/>
				<input type="text" id="etCharField"/>				
				<br>Select Reward Item:<br>
                <select name="etItemField" id="etItemField">
                    <option value="1">3x Amplification ES (S)     </option>
                    <option value="2">2x Scroll of Resurrection</option>
                    <option value="3">2x Scroll of Holy</option>
                </select> 
                <input type="submit" id="etCharSubmit" onclick="etLiteDoVoteDialog();" value="Vote!"/>

                
				
			</div>
			
		</div>
		
		<?php
		
	}
	
}

?>
inc.conf.php
PHP:
if ($_POST['etVoteItem'] == 1) {
	$voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($_POST['etVoteItem'] == 2) {
	$voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($_POST['etVoteItem'] == 3) {
	$voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}
vote.js
PHP:
function etLiteGetVoteDialog()
{
	
	$("#et_vcharenter").fadeIn(500);
	
}

function etLiteDoVoteDialog()
{
	
	var etVoteCharacter = escape(encodeURI(document.getElementById("etCharField").value));
	var etVoteItem = escape(encodeURI(document.getElementById("etItemField").value)); 
	
	$("#et_vcharenter").fadeOut(500);
	$("#et_vbutton").fadeOut(500);
	
	$.post('index.php', { etCharacter : etVoteCharacter, doVote : 1 , etItem: etVoteItem},
	function(data) {
		
		$("body").html(data);
		
	});
	
}

function etOpenVoteWindow()
{
	
	var VoteWindow = window.open(etVoteLink, "VOTE", "resizable=no,width=400,height=500");
	
}

What did I do wrong?
 
Stop bumping for no reason, you were still on the first page...

Here:
Code:
if ($_POST['etVoteItem'] == 1) {
    $voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($_POST['etVoteItem'] == 2) {
    $voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($_POST['etVoteItem'] == 3) {
    $voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}
You say you want to get 'etVoteItem'
but here:

Code:
                <select name="etItemField" id="etItemField">
                    <option value="1">3x Amplification ES (S)     </option>
                    <option value="2">2x Scroll of Resurrection</option>
                    <option value="3">2x Scroll of Holy</option>
                </select>
But here you call it etItemField...
So change one of those.
 
Stop bumping for no reason, you were still on the first page...

Here:
Code:
if ($_POST['etVoteItem'] == 1) {
    $voteReward = array("itemName" => "Scroll of Experience ES (S)", "itemId" => 30148, "itemAmount" => 3);
}

if ($_POST['etVoteItem'] == 2) {
    $voteReward = array("itemName" => "Scroll of Resurrection", "itemId" => 10431, "itemAmount" => 2);
}

if ($_POST['etVoteItem'] == 3) {
    $voteReward = array("itemName" => "Scroll of Holy", "itemId" => 10426, "itemAmount" => 2);  
}
You say you want to get 'etVoteItem'
but here:

Code:
                <select name="etItemField" id="etItemField">
                    <option value="1">3x Amplification ES (S)     </option>
                    <option value="2">2x Scroll of Resurrection</option>
                    <option value="3">2x Scroll of Holy</option>
                </select>
But here you call it etItemField...
So change one of those.

Sorry for the bumps.

Well I did the etVoteItem because of this line:
PHP:
    var etVoteItem = escape(encodeURI(document.getElementById("etItemField").value));
^that was in the vote.js so i thought maybe the etVoteItem stands for the etItemField because I tried the etItemField but it didn't work.
 
Back