problem retrieving value from DB into a checkbox

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

  1. #1

    Default problem retrieving value from DB into a checkbox

    I am very new to ASP/DB, so please bear with me.

    In my "add data" form, through checkboxes I am entering "Yes" values.
    (no "No" values, those are blank)

    Each checkbox equals a coloumn in my DB, if checked it places "Yes" as
    a value, if left unchecked it has no value. ( I know...I did not use
    Yes/No fields)

    In my "update form" I am trying to retrieve the earlier entered "Yes"
    values into checkboxes, but I can't seem to get anything.

    I tried all kinds of variations of this line, this is the latest:

    <input name="Badges_Buttons" value="<% If
    Request.Form("Badges_Buttons") = "Yes" Then Response.Write ("checked")
    %>" type="checkbox" size="30" maxlength="30">Badges &amp; Buttons<br>

    What am I doing wrong?

    Thanks.
    M
    Maria Kovacs Guest

  2. Similar Questions and Discussions

    1. Problem retrieving data from SQL Server
      I am a newbie to both SQL Server and webservices. I have mostly done programing in Foxpro, VB6, and a little C++, and VB.net. I have been able to...
    2. PHP problem retrieving data
      I'm not sure why this isn't working, but it's giving me no output. I have a form which requests email and city to pull up a listing, then Email that...
    3. [PHP] retrieving form checkbox values
      This is not necessary, you can do foreach($_POST as $file) { // ... } George Pitcher wrote:
    4. retrieving form checkbox values
      I have a form which I want to post multiple values from one function to another using checkboxes. Having one value is simple- the form submits the...
    5. Problem Retrieving data from an SQL Query in ASP
      You can create a table variable inside your code and insert the data from the cursor into it. Finally, return the table variable back to your ASP....
  3. #2

    Default Re: problem retrieving value from DB into a checkbox

    I didn't fully follow your explanation, but the one thing I noticed is that
    if your condition is true, you're going to wind up with:

    <input name="Badges_Buttons" value="checked" type="checkbox" size="30"
    maxlength="30">Badges &amp; Buttons<br>

    Notice that you have
    value="checked"

    It should be

    value="whatever the value should be" checked

    So, try

    <input name="Badges_Buttons" value="something"<% If
    Request.Form("Badges_Buttons") = "Yes" Then Response.Write (" checked")%>"
    type="checkbox" size="30" maxlength="30">Badges &amp; Buttons<br>

    Maxlength for a checkbox?

    Ray at home


    "Maria Kovacs" <mariakovacs@lycos.com> wrote in message
    news:6f76be22.0309241229.7cdc2d78@posting.google.c om...
    > I am very new to ASP/DB, so please bear with me.
    >
    > In my "add data" form, through checkboxes I am entering "Yes" values.
    > (no "No" values, those are blank)
    >
    > Each checkbox equals a coloumn in my DB, if checked it places "Yes" as
    > a value, if left unchecked it has no value. ( I know...I did not use
    > Yes/No fields)
    >
    > In my "update form" I am trying to retrieve the earlier entered "Yes"
    > values into checkboxes, but I can't seem to get anything.
    >
    > I tried all kinds of variations of this line, this is the latest:
    >
    > <input name="Badges_Buttons" value="<% If
    > Request.Form("Badges_Buttons") = "Yes" Then Response.Write ("checked")
    > %>" type="checkbox" size="30" maxlength="30">Badges &amp; Buttons<br>
    >
    > What am I doing wrong?
    >
    > Thanks.
    > M

    Ray at Guest

  4. #3

    Default Re: problem retrieving value from DB into a checkbox

    Sorry for the hazy explanation. All I am trying to do is retrieve
    information for editing from a coloumn that contains the value "Yes"
    and display it in a checkbox.
    You were right about the maxlength, that stayed there from an earlier
    version I tried for text.

    So now my code looks like this, and it still does not work:

    <input name="Toys" value="Yes" <% If Request.Form("Toys") = "Yes" Then
    Response.Write ("checked")%> type="checkbox">
    Maria Kovacs Guest

  5. #4

    Default Re: problem retrieving value from DB into a checkbox

    where "Toys" is name of the field
    and "Yes" is value, entered according whether the supplier carried toys or not.
    Maria Kovacs Guest

  6. #5

    Default Re: problem retrieving value from DB into a checkbox

    Sorry for the hazy explanation. All I am trying to do is to retrieve
    information for editing from a field (say: Toys) and display it into a
    checkbox. If the supplier carried toys the field value is "Yes" if it
    doesn't carry doys the field doesn't contain anything.

    Following your advice, now my code looks like this but my checkboxes
    are still empty:
    <input name="Toys" value="Yes" <% If Request.Form("Toys") = "Yes" Then
    Response.Write("checked")%> type="checkbox"> Toys</font></td>
    Maria Kovacs Guest

  7. #6

    Default Re: problem retrieving value from DB into a checkbox

    Still don't work:
    <input name="Toys" value="Yes" <% If Request.Form("Toys") = "Yes" Then
    Response.Write ("checked")%> type="checkbox">Toys</font></td>

    (Sorry if I may multiple posted but my posts don't seem to appear in
    the thread.)
    Maria Kovacs Guest

  8. #7

    Default Re: problem retrieving value from DB into a checkbox

    What datatype is this Toys column in your Access database? I believe you
    said that it is NOT a "yes/no" datatype, correct? Let's find out what the
    value is --- oh, wait, you're pulling from request.form. Sorry.

    So like, the value of this checkbox will only be "Yes" if you have already
    checked the box and submitted the form back to itself, you realize, right?
    If you do that, it should work as you have it. Try loading this page,
    checking the box, and submitting the form.


    testpage.asp:

    <html><body>
    <form method="post" action="testpage.asp">
    <input name="Toys" value="Yes" <% If Request.Form("Toys") = "Yes" Then
    Response.Write ("checked")%> type="checkbox">
    <input type="submit">
    </form>
    </body></html>



    Ray at work


    "Maria Kovacs" <mariakovacs@lycos.com> wrote in message
    news:6f76be22.0309250729.5f3468dd@posting.google.c om...
    > Sorry for the hazy explanation. All I am trying to do is retrieve
    > information for editing from a coloumn that contains the value "Yes"
    > and display it in a checkbox.
    > You were right about the maxlength, that stayed there from an earlier
    > version I tried for text.
    >
    > So now my code looks like this, and it still does not work:
    >
    > <input name="Toys" value="Yes" <% If Request.Form("Toys") = "Yes" Then
    > Response.Write ("checked")%> type="checkbox">

    Ray at Guest

  9. #8

    Default Re: problem retrieving value from DB into a checkbox

    That's okay. MS's news server has been a bit choppy the past couple of
    days. I imagine that they're trying to filter out and prevent all those
    virus posting.

    Ray at work

    "Maria Kovacs" <mariakovacs@lycos.com> wrote in message
    news:6f76be22.0309250825.64365b85@posting.google.c om...
    > Still don't work:
    > <input name="Toys" value="Yes" <% If Request.Form("Toys") = "Yes" Then
    > Response.Write ("checked")%> type="checkbox">Toys</font></td>
    >
    > (Sorry if I may multiple posted but my posts don't seem to appear in
    > the thread.)

    Ray at Guest

  10. #9

    Default Re: problem retrieving value from DB into a checkbox

    I finally got it working. As you pointed out, the problem was with the
    Request.Form. I was retrieving info from the form and not from the
    database. So replacing that with rsVIPP solved my problem. Here is the
    code, and it flies :)

    <input name="Toys" value="Yes" <% If rsVIPP("Toys") = "Yes" Then
    Response.Write ("checked")%> type="checkbox">Toys

    Thanks for your help.
    M
    Maria Kovacs 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