Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Update database - checkbox

LEGEND ,
Feb 28, 2007 Feb 28, 2007
I'm using the code below on my update page, but the checkbox value sin't
being inserted in to the database. Everything else is working fine.

Any Ideas???
Thanks
Andy

Mt checkbox code is:

<input <%If (CStr((ProductsRS.Fields.Item("Accessory").Value)) =
CStr("True")) Then Response.Write("checked=""checked""") :
Response.Write("")%> name="accessory_box" type="checkbox"
id="accessory_box">


if AccessGroupID <> 2 then
if Request("selected") <> "" then
ProductsRS("sagecode")=Request("sagecode")
ProductsRS("Product")=Request("Product")
ProductsRS("Description")=Request("EditorValue")
ProductsRS("offer_text")=Request("offer_text")
ProductsRS("offer_link")=Request("offer_link")
ProductsRS("CategoryID")=Request("CategoryID")
ProductsRS("ManufacturerID")=Request("ManufacturerID")
ProductsRS("ListPrice")=DoNull(Request("ListPrice"))
ProductsRS("Percentage")=DoNull(Request("Percentage"))
ProductsRS("Price")=DoNull(Request("ListPrice"))-discount
ProductsRS("Savings")=discount
ProductsRS("Break1")=DoNull(Request("Break1"))
ProductsRS("Price2")=DoNull(Request("Price2"))
ProductsRS("Break2")=DoNull(Request("Break2"))
ProductsRS("Price3")=DoNull(Request("Price3"))
ProductsRS("Break3")=DoNull(Request("Break3"))
ProductsRS("InStock")=DoNull(Request("InStock"))
ProductsRS("Accessory")=Request("accessory_box")
ProductsRS.Update


TOPICS
Server side applications
255
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 28, 2007 Feb 28, 2007
It is not saving into the DB because you aren't setting the value of the checkbox: value="true"
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2007 Mar 01, 2007
Thanks for that envision3d

That does now show the checkbox as checked if the database field has a value
of 'True'
Now i need to be able to insert the value into the database for my
insert/update page.

The code i'm using for the rest of my insert/update is:

ProductsRS("Accessory")=Request("accessory_box")
ProductsRS.Update

Thanks
Andy




"envision3d" <webforumsuser@macromedia.com> wrote in message
news:es481q$3vv$1@forums.macromedia.com...
> This is because you cannot "response.write" code, this writes to the
> screen.
> And I don't see where you set the value of the checkbox. If you wanted to
> run
> a check then do it before the checkbox maybe somthing like:
>
> <%
> dim chkBoxValue
>
> if (CStr((ProductsRS.Fields.Item("Accessory").Value)) = CStr("True"))
> Then
> chkBoxValue = "checked"
> else
> chkBoxValue = "notChecked"
> end if
> %>
>
> <input type="checkbox" value="<%=chkBoxValue%> name="myCheckBox">
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 01, 2007 Mar 01, 2007
LATEST
Its ok - :-)
I was using yes/no instead of ture/false - - - -

Thanks again envision3d

Andy


"Andy" <me@work.com> wrote in message
news:es6954$llk$1@forums.macromedia.com...
> Thanks for that envision3d
>
> That does now show the checkbox as checked if the database field has a
> value of 'True'
> Now i need to be able to insert the value into the database for my
> insert/update page.
>
> The code i'm using for the rest of my insert/update is:
>
> ProductsRS("Accessory")=Request("accessory_box")
> ProductsRS.Update
>
> Thanks
> Andy
>
>
>
>
> "envision3d" <webforumsuser@macromedia.com> wrote in message
> news:es481q$3vv$1@forums.macromedia.com...
>> This is because you cannot "response.write" code, this writes to the
>> screen.
>> And I don't see where you set the value of the checkbox. If you wanted
>> to run
>> a check then do it before the checkbox maybe somthing like:
>>
>> <%
>> dim chkBoxValue
>>
>> if (CStr((ProductsRS.Fields.Item("Accessory").Value)) = CStr("True"))
>> Then
>> chkBoxValue = "checked"
>> else
>> chkBoxValue = "notChecked"
>> end if
>> %>
>>
>> <input type="checkbox" value="<%=chkBoxValue%> name="myCheckBox">
>>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines