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

Discussion in 'Javascript' started by Borg Vomit, Sep 18, 2003.

  1. Borg Vomit

    Borg Vomit Guest

    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('</font></b></td>');
    document.writeln('<input type="hidden"name="QID" value= & pAnswer &
    >');

    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>
     
    Borg Vomit, Sep 18, 2003
    #1
    1. Advertising

  2. Borg Vomit

    Atrax Guest

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

    try

    microsoft.public.inetserver.asp.general

    but from a preliminary inspection I'd say you've forgotten to set the
    @Language declaration to 'JScript'


    ________________________________________
    Atrax. MVP, IIS
    http://rtfm.atrax.co.uk/

    newsflash : Atrax.Richedit 1.0 now released.
    http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Atrax, Sep 18, 2003
    #2
    1. Advertising

  3. Borg Vomit

    Borg Vomit Guest

    Atrax <> wrote in message news:<3f69354d$0$62078$>...
    > 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.
     
    Borg Vomit, Sep 18, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    558
    Juan T. Llibre [MVP]
    Dec 14, 2004
  2. jalkadir
    Replies:
    2
    Views:
    405
  3. Bruno Sousa

    CGI::Session just don't work

    Bruno Sousa, Aug 7, 2009, in forum: Ruby
    Replies:
    3
    Views:
    209
    7stud --
    Aug 7, 2009
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    948
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Chris Angelico
    Replies:
    0
    Views:
    85
    Chris Angelico
    May 30, 2014
Loading...

Share This Page