Check Boxes not recording data

S

Sam

I have an online form which is submitted to a SQL database. The check boxes
on the form are not recording any data.

I have checked the links to the database and this are viable but it is still
not recording.

All other boxes on the form (i.e. dropdown, text etc) all seem to be working
ok but I seem to be at a lost end with this one.

I would appreciate it if anyone could help

Thanks
 
S

Sam

As below

<input type="checkbox" name="Dressingssupplied" value="Dressingsupplied"
tabindex="36" style="font-weight: 700">

Thank you
 
D

David Berry

Normally a checkbox would have a value of ON/OFF, TRUE/FALSE or YES/NO. You
appear to be using a text value. What type of field is this in your
database? Is it text, bit etc? If it's a Yes/No field in the database
(Bit) then you need to use that when you do your update. Ex:

If your database field was a BIT or TRUE/FALSE then the checkbox would be:

<input type="checkbox" name="Dressingssupplied" value="ON"
tabindex="36" style="font-weight: 700">

Then on the update page you could do this:

strDressingssupplied = Request.Form("Dressingssupplied")

if trim(ucase(strDressingssupplied)) = "ON" then
strDressingssupplied = "1"
else
strDressingssupplied = "0"
end if

(or make the above TRUE and FALSE depending on what your database is set
for.


Then in your update you'd have

UPDATE TABLENAME SET Dressingssupplied = " & strDressingssupplied
 
D

David Berry

Glad to help!

For future note, when an update (or insert) fails always check what the
database field is and then what's being passed to it. You can do
"debugging" by doing a Response.Write on your SQL Statement (before the
update or insert occurs) to see what the code is trying to pass to the
database. That way you can look for any issues.
 
Top