I'm so close, but it just don't work -- Newbie needs help

B

Borg Vomit

I'm not a script guy, and this is kicking my ass:

I need to check the values of poll.htm against an MS Access DB and
then build a table so the poll taker can do a final review. After poll
taker approves the text values (the numaric values are placed in
hidden fields) will be stored in the data base (that code is not shown
below).

Issue 1:
pTitle & pAnswer should be the value from the db, pasted up from the
function.

I have no idea how to insert it using a document.write



Issue 2:
if i don't put the <% and %> down in the function I get: server
undefined.

if I do put them there I get:


Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/PollingTry2/SurveyWork1.asp, line 144, column 96
var strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='C:\Inetpub\wwwroot\fpdb\poll.mdb';";
-----------------------------------------------------------------------------------------------^


I got the sample db code from MSDN and it should be javascript, but
the error message says VBScript.

So, I need to get set the variables down in function "ListValue". Or
should I use some kind of return method. How do I return 2 variables?



This is the code from my asp page. there's nothing in the header to
speak of.

<body>
<SCRIPT LANGUAGE="JavaScript" RUNAT="server">

<!--

var i, pos, argname, value, queryString, pairs,pAnswer, Q,pVal,
pTitle,CellBG,FontColor;

queryString = location.search.substring(1);

pairs = queryString.split("&");


//start the table


document.writeln('<table border="1" cellpadding="4" cellspacing="0"
style="border-collapse: collapse" bordercolor="#FBAE4A" width="67%"
id="AutoNumber2" height="313">');

//run through the values of the poll page


for (i = 0; i < pairs.length; i++)
{
pos = pairs.indexOf('=');
if (pos == -1)
{
continue;
}
argname = pairs.substring(0,pos);
value = pairs.substring(pos+1);

// argname is the name of the radio button
//value is the value of the radio button


switch (argname){
case 'QID1' : // Title: Question 1?


//go to the listvalue function and check the values against the db

ListValue(argname, value);



if (pAnswer ="None Selected") {
CellBG = '#000000';
FontColor = '#FF66FF';
} else {
CellBG = '#193789';
FontColor = '#00FF00';
}



document.writeln('<tr>');

//pTitle should be the value from the db *********


document.writeln('<td width= "83%" height= "40" bgcolor=
"CellBG">pTitle</td>');
document.writeln('<td width= "17%" height= "40" align= "center">');
document.writeln('<p align= "center"><b><font color= "FontColor">');

//pAnswer should be the value from the db ***********

document.writeln(pAnswer)

document.writeln(' said:
document.writeln('</tr>');
break;

}

document.writeln("</table>");


function ListValue(Q,pVal)
{
// record variables
// var fld, filter
//var showBlank = " "
//dim showNull = "-NULL-"
Dim SQLPollValues

// connection and recordset variables
set Cnxn = Server.CreateObject("ADODB.Connection")
strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source='C:\Inetpub\wwwroot\fpdb\poll.mdb';"
set rsPollValues = Server.CreateObject("ADODB.Recordset")
SQLPollValues = "SELECT * FROM Qry_Answers WHERE QID=" & Q & " AND
answer_id='" & pVal & "'"




//open connection
Cnxn.Open(strCnxn)

// create recordset client-side using object refs
rsPollValues.ActiveConnection = Cnxn
rsPollValues.CursorLocation = adUseClient
rsPollValues.CursorType = adOpenKeyset
rsPollValues.LockType = adLockOptimistic
rsPollValues.Source = SQLPollValues
rsPollValues.Open()

rsPollValues.MoveFirst()

if (rsPollValues.RecordCount = 0) then
Response.Write("No records matched ")
Response.Write (SQLPollValues + "So cannot make table...")
Cnxn.Close()
Response.End

else
if (Q = 9) then
pAnswer = rs.field("answer")
pTitle = rs.field("title")
else
pAnswer = rs.field("StateFullName")
pTitle = rs.field("title")

end if
end if



// Response.Write(e.message)



// finally

// clean up
if (rsPollValues.State = adStateOpen) then
rsPollValues.Close
end if

if (Cnxn.State = adStateOpen) then
Cnxn.Close
rsPollValues = null
Cnxn = null
end if




}
//-->
</script>
</body>
 
B

Borg Vomit

Atrax said:
given that this error is an ASP error, don't you think posting in an ASP
group would be better?


No, because most of the script works even if it's not saved as an asp
page. In any case I think this is a scripting error, unrelated to asp.
Changing the ex to asp was just a last ditch effort to get it to work
before asking the group for help. I wanted to do as much as I could
to avoid having some twit respond with a less than helpful reply.

I'm also hoping that someone may have a better, non-asp method for
doing this.

Maybe you could go to the asp group and troll and direct traffic
there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top