Avatar of johnhardy
johnhardy
Flag for United Kingdom of Great Britain and Northern Ireland asked on

check boxes will not show correct state

Hello

I have some tick boxes in an update form eg
<input name="UserBooks-Charts" type="checkbox" id="UserBooks-Charts" value="1">
When the tick box is ticked on the form and an update is carried out the record in the access database shows the tick correctly.

However the tick does not show in the checkbox on the form, so if another update is carried out the record is updated again and the tick in the yes/no field disappears.

Is there a way I can get the tick boxes to show on the form when the field is marked 1 ie (ticked)

I have asked this question before but it is still a problem.
Thanks
John
Adobe Dreamweaver

Avatar of undefined
Last Comment
Cem Türk

8/22/2022 - Mon
Cem Türk

the checkbox should be ticked depending on the record  when update page is loaded.

you can use a code like this(if you are using PHP)

<input name="UserBooks-Charts" type="checkbox" id="UserBooks-Charts" value="1"<?php if($row[tickbox]==1) {echo 'checked';}?>>

shortly your HTML should look like the following if record in database is ticked

<input name="UserBooks-Charts" type="checkbox" id="UserBooks-Charts" value="1" checked>
johnhardy

ASKER
Thanks for that,  I am using .asp
Can you help me with .asp ?

ASKER CERTIFIED SOLUTION
Cem Türk

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
johnhardy

ASKER
Thanks

<td><input name="UserBooks-Charts" type="checkbox" id="UserBooks-Charts" value="1" <%if LoggedIn("UserBooksChartsetc") = 1 then response.write("checked") end if
%>></td>

This seems to be whats required but the tick is  not showing in the box.

It is in the record OK
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Cem Türk

it seems that we are not able to match the value in the db correctly, what do you save in the db if the checkbox is ticked?
johnhardy

ASKER
Thanks
Sorry for the delay.
My server is out of action so I am not getting emails

In access the yes/no files shows as a tick, if I export to a txt file the field shows as  1 and 0
johnhardy

ASKER
I am working in Dreamweaver
I notice the the server behaviour has a red exclamation mark against it which if I try to open I received the message "Before using the server behaviour please creat a recordset"
The recordset is there correctly named and works for all the text fields.

Is this an indication of where things are wrong?
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
johnhardy

ASKER
I changed this

<input name="UserBooks-Charts" type="checkbox" id="UserBooks-Charts" value="1"<% if rs("tickbox") = 1 then
response.write("checked")
end if
%>>

To
<input name="UserBooks-Charts" type="checkbox" id="UserBooks-Charts" value="1"<% if rs("tickbox") = True then
response.write("checked")
end if
%>>

and it seems to be working OK
Does that make sense?
Cem Türk

well then the stored value in db was True or False :]
johnhardy

ASKER
It definitely shows yes/no in the access design view
Your help has saved me hundreds of hours of internet surfing.
fblack61
johnhardy

ASKER
Thanks very much for all the help
Cem Türk

your welcome