PDA

View Full Version : accessing an .asp file


aspenlumberjack
02-29-2004, 09:50 PM
I am working through a tutorial book on Action Script. This excercise
has a 'online poll' where
you can cast your vote in a radio button, submit those and get the
results returned on a page
with bargraphs.

see: www22.brinkster.com/mountain2ocean/poll2.swf

An .asp file as well as a .mdb file are supplied with the book on a cd.
(Poll.asp
Poll.mdb )

I uploaded all as instructed.

I checked, double, triple and quadruple checked my .fla for typo's,
etc. In the end I copied and pasted the code from the books' cd with completed excercises to make sure it's correct without typos and errors.

in the code the URL is referred to as:
pollURL = "http://www22.brinkster.com/mountain2ocean/poll.asp";

My .swf is in the same directory as the .asp and .mdb.
the actual swf (and the nature of the problem) I tried, uppercase,
lowercase, I tried everything. Why won't it show the percentages? Is it not accessing the asp file?

Please help me out I'm trying to learn this on my own and have no help,
this particular part
(data in and out of the server) I would really like to master. Please
help me I'm stuck


Thanks Danno



additional: some of the code

stop();
pollURL = "http://www22.brinkster.com/mountain2ocean/poll2.swf";
function pollLoaded() {
_root.gotoAndStop("display");
}
poll = new LoadVars();
poll.onLoad = pollLoaded;
function submitChoice() {
var choice = radioGroup.getData();
poll.load(pollURL+"?choice="+choice);
_root.gotoAndStop("waiting");
}


Then there is the actual return and display code

for (i=1;i<=4;++i) {
var graphName="barGraph"+i;
var votes=poll["item"+i+"total"];
var totalVotes=poll.totalVotes;
var percent=Math.round((votes/totalVotes)*100);
_root[graphName].bar._xscale=percent;
_root[graphname].topPercent.text=percent+"%";
_root[graphname].bottomPercent.text=percent+"%";
}


PS the radio buttons choice values are respectively 1,2,3,4

Cota
02-29-2004, 10:12 PM
This might be a stupid question, but does your server support ASP files? Does the Database need a DSN? Have you checked those little details yet?

aspenlumberjack
02-29-2004, 10:18 PM
yes the server does support asp files.

Cota
02-29-2004, 10:42 PM
try changing this line

var choice = radioGroup.getData();
poll.load(pollURL+"?choice="+choice);

to

_global.choice = radioGroup.getData();
poll.load(pollURL+"?choice="+_global.choice);

and on the very first frame of the main time line, add this as a frame action

_global.choice;

Sometimes using just var choice doesnt always allocate the variable.

aspenlumberjack
02-29-2004, 11:23 PM
Cota, thank you for the help, it's driving me over the edge.

I tried to alter the code as suggested but there still is no data returned. Any idea how to narrow it down where the kink could be?
Thanks so much for the support

Cota
02-29-2004, 11:27 PM
There are a few ways to narrow it down. First lets make sure the ASP file is processing correctly. In the ASP file, hardcode a value for the incoming choice variable. Then run it by itself and check the output. Also, make sure you're using the correct Response.Write sytax in the ASP file. If that works then the problem is with the actionscript, or the Response.Write. Then the fun really begins.

aspenlumberjack
03-01-2004, 06:06 PM
The problem is that my particular server requires to have the poll.mdb file in a /db/ subdirectory(that is for all all .mdb files). Even stronger, when I had a copy of the .mdb file in both the root as well as that sub directory (I suspected the asp coudn't find the .mdb) the thing wouldn't work!

Is that normal on servers?

Danno, thanks for the help everyone.

Cota
03-01-2004, 06:16 PM
Usually when a specific subdirectory is allocated for a DB file such as .MDB, it really refers to the file permissions. If you have the same DB existing in two places at once, depending on whcih method you're using for connection, it could confuse the server.
Are you sure the ASP file is finding the DB, if thats the case, post the ASP connection code and we'll see if we cant fix it.