Passing db values to function

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Passing db values to function

    Hello,
    I am creating dynamic images with corresponding checkboxes by pulling
    data from an Access database. The onchange event of the checkboxes
    calls a javascript function which basically stores the image name
    taken from the database into an array. Unfortunately I am having a
    problem doing this the way I would like. I have no problem passing
    the primary key from the Access database (IDNum), which is an
    autonumber, but I am unable to pass the name of the image (Name) which
    I have designated as a text data type. I get an error message telling
    me the value I am trying to pass is undefined. I would appreciate any
    help on this.

    Dim connCW, strQuery, rsItem, counter

    'Create and open the database connection object
    Set connCW = Server.CreateObject("ADODB.Connection")
    connCW.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
    "DBQ=" & Server.MapPath("../db/Library.mdb")
    SET rsItem = connCW.Execute("SELECT * FROM
    "&request.querystring("pres")&" WHERE
    Category='"&request.querystring("cat")&"'")

    counter=1

    Response.write "<table cellpadding=0 cellspacing=0><tr>"
    Do While Not rsItem.EOF

    Response.Write "<td align=center width=200><a
    href=FullView.asp?Slide="&rsItem("Name")&"><img
    src=../"&request.querystring("pres")&"/"&request.querystring("cat")&"/Slides/150/"&rsItem("Name")&"
    border=0 width=150 height=113></a><br>"

    'this DOES NOT work as it is now, but works if I change "Name" to
    "IDNum"
    Response.Write "<input type=checkbox name="&counter&"
    onchange=javascript:checkBoxes("& rsItem("Name") &")></td>"

    if counter mod 4=0 then
    Response.Write "</tr><tr><td>&nbsp</td></tr><tr>"
    end if
    counter=counter+1
    rsItem.MoveNext
    Loop
    response.write "</table>"

    connCW.close()
    Darby Guest

  2. Similar Questions and Discussions

    1. winhttp passing values
      Hello, I have the following structure, Form page My Server 2nd server html ---------->My.asp------->2server.asp User can...
    2. passing through values
      Hello i wanna pass through the value model like this <form method="get" action="meeet.htm"> <div align="center">Nummer: <input type="input"...
    3. Passing a variable to a package function vs. a local function
      I'm a bit new to this so please bear with me... I've written a script that uses CGI.pm something like this: use CGI::Carp qw(fatalsToBrowser);...
    4. VBS file passing values to ASP URL
      Hi, I have a VBS file and I would like to call an ASP web page and pass it values in the URL. Is this possible?? Cheers,
    5. Passing values from one page to another
      Hello all, -------------------------------------------- //Page0.php <a href="page1.php?empid=1">Enter</a>...
  3. #2

    Default Re: Passing db values to function

    Because on the Javascript side, the name is a string - you need to enclose
    it in 's. Otherwise, Javascript will think it is a variable you haven't
    defined, and hence the error.

    Try:

    Response.Write "<input type=checkbox name="&counter&"
    onchange=javascript:checkBoxes('"& rsItem("Name") & "')></td>"



    --
    Manohar Kamath
    Editor, .netWire
    [url]www.dotnetwire.com[/url]


    "Darby" <darby_chris@hotmail.com> wrote in message
    news:88c20d1b.0408061126.767cd8c8@posting.google.c om...
    > Hello,
    > I am creating dynamic images with corresponding checkboxes by pulling
    > data from an Access database. The onchange event of the checkboxes
    > calls a javascript function which basically stores the image name
    > taken from the database into an array. Unfortunately I am having a
    > problem doing this the way I would like. I have no problem passing
    > the primary key from the Access database (IDNum), which is an
    > autonumber, but I am unable to pass the name of the image (Name) which
    > I have designated as a text data type. I get an error message telling
    > me the value I am trying to pass is undefined. I would appreciate any
    > help on this.
    >
    > Dim connCW, strQuery, rsItem, counter
    >
    > 'Create and open the database connection object
    > Set connCW = Server.CreateObject("ADODB.Connection")
    > connCW.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
    > "DBQ=" & Server.MapPath("../db/Library.mdb")
    > SET rsItem = connCW.Execute("SELECT * FROM
    > "&request.querystring("pres")&" WHERE
    > Category='"&request.querystring("cat")&"'")
    >
    > counter=1
    >
    > Response.write "<table cellpadding=0 cellspacing=0><tr>"
    > Do While Not rsItem.EOF
    >
    > Response.Write "<td align=center width=200><a
    > href=FullView.asp?Slide="&rsItem("Name")&"><img
    >
    src=../"&request.querystring("pres")&"/"&request.querystring("cat")&"/Slides
    /150/"&rsItem("Name")&"
    > border=0 width=150 height=113></a><br>"
    >
    > 'this DOES NOT work as it is now, but works if I change "Name" to
    > "IDNum"
    > Response.Write "<input type=checkbox name="&counter&"
    > onchange=javascript:checkBoxes("& rsItem("Name") &")></td>"
    >
    > if counter mod 4=0 then
    > Response.Write "</tr><tr><td>&nbsp</td></tr><tr>"
    > end if
    > counter=counter+1
    > rsItem.MoveNext
    > Loop
    > response.write "</table>"
    >
    > connCW.close()

    Manohar Kamath [MVP] Guest

  4. #3

    Default Re: Passing db values to function

    "Manohar Kamath [MVP]" <mkamath@TAKETHISOUTkamath.com> wrote in message news:<O65quEAfEHA.3732@TK2MSFTNGP11.phx.gbl>...
    > Because on the Javascript side, the name is a string - you need to enclose
    > it in 's. Otherwise, Javascript will think it is a variable you haven't
    > defined, and hence the error.
    >
    > Try:
    >
    > Response.Write "<input type=checkbox name="&counter&"
    > onchange=javascript:checkBoxes('"& rsItem("Name") & "')></td>"
    >
    >
    >
    > --
    > Manohar Kamath
    > Editor, .netWire
    > [url]www.dotnetwire.com[/url]
    >
    >
    > "Darby" <darby_chris@hotmail.com> wrote in message
    > news:88c20d1b.0408061126.767cd8c8@posting.google.c om...
    > > Hello,
    > > I am creating dynamic images with corresponding checkboxes by pulling
    > > data from an Access database. The onchange event of the checkboxes
    > > calls a javascript function which basically stores the image name
    > > taken from the database into an array. Unfortunately I am having a
    > > problem doing this the way I would like. I have no problem passing
    > > the primary key from the Access database (IDNum), which is an
    > > autonumber, but I am unable to pass the name of the image (Name) which
    > > I have designated as a text data type. I get an error message telling
    > > me the value I am trying to pass is undefined. I would appreciate any
    > > help on this.
    > >
    > > Dim connCW, strQuery, rsItem, counter
    > >
    > > 'Create and open the database connection object
    > > Set connCW = Server.CreateObject("ADODB.Connection")
    > > connCW.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
    > > "DBQ=" & Server.MapPath("../db/Library.mdb")
    > > SET rsItem = connCW.Execute("SELECT * FROM
    > > "&request.querystring("pres")&" WHERE
    > > Category='"&request.querystring("cat")&"'")
    > >
    > > counter=1
    > >
    > > Response.write "<table cellpadding=0 cellspacing=0><tr>"
    > > Do While Not rsItem.EOF
    > >
    > > Response.Write "<td align=center width=200><a
    > > href=FullView.asp?Slide="&rsItem("Name")&"><img
    > >
    > src=../"&request.querystring("pres")&"/"&request.querystring("cat")&"/Slides
    > /150/"&rsItem("Name")&"
    > > border=0 width=150 height=113></a><br>"
    > >
    > > 'this DOES NOT work as it is now, but works if I change "Name" to
    > > "IDNum"
    > > Response.Write "<input type=checkbox name="&counter&"
    > > onchange=javascript:checkBoxes("& rsItem("Name") &")></td>"
    > >
    > > if counter mod 4=0 then
    > > Response.Write "</tr><tr><td>&nbsp</td></tr><tr>"
    > > end if
    > > counter=counter+1
    > > rsItem.MoveNext
    > > Loop
    > > response.write "</table>"
    > >
    > > connCW.close()
    Thanks Manohar, that did it for me.

    Chris.
    Darby Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139