Professional Web Applications Themes

Passing db values to function - ASP Database

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 ...

  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. #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_chrishotmail.com> wrote in message
    news:88c20d1b.0408061126.767cd8c8posting.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

  3. #3

    Default Re: Passing db values to function

    "Manohar Kamath [MVP]" <mkamathTAKETHISOUTkamath.com> wrote in message news:<O65quEAfEHA.3732TK2MSFTNGP11.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_chrishotmail.com> wrote in message
    > news:88c20d1b.0408061126.767cd8c8posting.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

Similar Threads

  1. Passing values to a headerRenderer
    By Verata in forum Macromedia Flex General Discussion
    Replies: 0
    Last Post: November 14th, 01:15 PM
  2. Passing List Values
    By hecsan in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: July 7th, 04:23 PM
  3. Datagrid/SQL & passing values
    By VFR in forum ASP.NET Data Grid Control
    Replies: 3
    Last Post: February 6th, 01:47 PM
  4. passing through values
    By Jeroen van Vliet in forum Macromedia Flash
    Replies: 1
    Last Post: January 12th, 06:37 AM
  5. Replies: 2
    Last Post: September 29th, 07:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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