Navigate
Home
ArticleWiki
Forum
Journal
Search
Newsletter
Links
Tech News
expertsrt.com
Welcome Guest.
Username:

Password:

Remember me

poll script
Welcome, Guest. Please login or register.
December 02, 2008, 08:55:14 AM
11304 Posts in 1248 Topics by 498 Members
Latest Member: katCheeme
Experts Round Table Network  |  Serverside Technology  |  ASP  |  poll script « previous next »
Pages: [1]
Author Topic: poll script  (Read 2193 times)
Johnny26652

Offline Offline

Posts: 61


« on: July 14, 2007, 04:15:06 PM »

Hi, looking around for a asp poll script. Have found quite a few but not one that does what i want.
If you know the bbc site they usually run a poll with one question, a yes or no option but once voted the panel changes to a bar chart with results in them.

This is what I want to do but can't for the life of me find a script out there that does it.

« Last Edit: July 14, 2007, 05:39:50 PM by Johnny26652 » Logged

Johnny
rdivilbiss
Moderator
*
Offline Offline

Posts: 414



WWW
« Reply #1 on: July 18, 2007, 08:05:31 PM »

I just wrote: http://www.rodsdot.com/ee/poll_vote_ajax_asp.asp

Unfortunately I'm getting an error in IE, but check it out in Firefox and see if it is something you want me to pursue.

Logged

Rod
rdivilbiss
Moderator
*
Offline Offline

Posts: 414



WWW
« Reply #2 on: July 18, 2007, 09:22:56 PM »

The IE error is fixed.

The original page displays the poll and vote buttons. The vote is posted to an ASP post handling page which receives the vote, stores it in the database then queries the database for the total results for each choice.  The original page receives the totals via the remote scripting object results, parses them and creates a percentage, then displays a dynamic bar chart of the results in place of the vote area.

Logged

Rod
Johnny26652

Offline Offline

Posts: 61


« Reply #3 on: July 19, 2007, 04:45:57 PM »

thanks rod.

i tried your code.. when i click on a button nothing happens.. i don't see any graphs or anything.. i copied your jpg's. how do i debug this program? this is my first ajax/asp so need your expertise.. really appreciate your time.

thanks again
Logged

Johnny
rdivilbiss
Moderator
*
Offline Offline

Posts: 414



WWW
« Reply #4 on: July 19, 2007, 05:05:08 PM »

On my site's example page nothing happens, or after copying the code to your site nothing happens?

I just tested my site's page in Opera, Firefox and IE successfully.

If it is your site's test page that isn't working send me a link or post the code so I can debug.
Logged

Rod
Johnny26652

Offline Offline

Posts: 61


« Reply #5 on: July 20, 2007, 05:12:11 PM »

i copied your code to my site and nothing happens... i copied and pasted so didn't change anything.. I don't have a web address just trying it on local web..

i was wondering if someone else tried this and had problems executing..

are there any ajax/asp tutorials... other than what you have on experts?

thanks again
john
« Last Edit: July 20, 2007, 05:14:20 PM by Johnny26652 » Logged

Johnny
rdivilbiss
Moderator
*
Offline Offline

Posts: 414



WWW
« Reply #6 on: July 20, 2007, 06:22:08 PM »

i copied your code to my site and nothing happens... i copied and pasted so didn't change anything.. I don't have a web address just trying it on local web..

What did you name the pages?

Note the second page name is hard coded in the JavaScript as 'poll_vote_ajax_asp_dovote.asp

If you named it something else and did not change the script in the first page, then you'll get a 404 error and never return anything.


For debugging use this function in place of the former, and add a division in the HTML.

Code:
function handleHttpResponse(pObjRequest, pElementId) {
if (pObjRequest.readyState==4) {
if (pObjRequest.status==200) {
document.getElementById('voteform').style.display='none';
document.getElementById('waiting').style.display='none';
document.getElementById('results').style.display='inline';
var votes = pObjRequest.responseText.split(',');
var tmp =  votes[0].split('=');
var yeses = parseInt(tmp[1]);
tmp =  votes[1].split('=');
var nos = parseInt(tmp[1]);

var yp = Math.round((yeses / (yeses + nos)) * 100);
var yn = Math.round((nos / (yeses + nos)) * 100);

var barchart = '<span>Do people Like broccoli</span><br>';
barchart += '<div class="votes"><div class="chart"><img border="0" src="images/1x15navy.gif" width="'+yp+'" height="15"></div>Yes: '+yp+'%</div>';
barchart += '<div class="votes"><div class="chart"><img border="0" src="images/1x15navy.gif" width="'+yn+'" height="15"></div>No: '+yn+'%</div>';
document.getElementById(pElementId).innerHTML=barchart;
pObjRequest=null;
}else{
document.getElementById('statuslog').innerHTML += 'Status: '+pObjRequest.status+'<br>';
}
}else{
document.getElementById('statuslog').innerHTML += 'Ready State: '+pObjRequest.readyState+'<br>';
}
}

And in the HTML

Code:
<div id="statuslog">Ajax Status:<br></div>

Which will show you what is going on with the response object.  If and when it fails it will be easy to determine why.

And of course, all of this assumes your local web is capable of running an ASP page.  e.g.

<%
response.write("ASP Works")
%>

Saved in a page all by it self called test.asp works correctly.
Logged

Rod
Pages: [1]
« previous next »
    Jump to: