Link to home
Start Free TrialLog in
Avatar of johnhardy
johnhardyFlag 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
Avatar of Cem Türk
Cem Türk
Flag of Türkiye image

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>
Avatar of johnhardy

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of Cem Türk
Cem Türk
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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?
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
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?
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?
well then the stored value in db was True or False :]
It definitely shows yes/no in the access design view
Thanks very much for all the help
your welcome