How to set checkbox to ticked?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

How to set checkbox to ticked?

#1

Postby alexmcclune » Thu Aug 28, 2014 8:32 am

Hi,

I feel this is a silly question but i will ask anyway.

I am populating a form from a database resource and one of the values is a 1 (Yes) or a 0(No). I am taking this value and if it is 1 I want to set it's associated form field (let's call it field1) to 1 - this is all fine, I can see it working in the log's.

However, the field control is a checkbox and I am really struggling to set it to ticked if the associated resource is 1...can anyone advise?

I have gone through the list of methods for controls.chk_field1.... and fields.field1...however I simply can't see anything?

Thanks, hopefully I am not trying to "misuse" the checkbox or ignore best practice etc.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Thu Aug 28, 2014 12:16 pm

If it's a checkbox, the field type must be boolean and you need to set the field value to true to show the checkbox as checked. The system will also let you use display type of checkbox with field types other than boolean, but these should only be used for lists. You won't be able to display the checkbox in this case unless you have a list. Bottom line: if it's not a list field, the field type must be boolean.

If you have a boolean field called BOOL1, any of these should work with Javascript:

Code: Select all

fields.BOOL1.value = true;
fields.BOOL1.value = 1;
fields.BOOL1.value = "Y";
If your using FPL, the equivalent would be:

Code: Select all

BOOL1 = true;
BOOL1 = 1;
BOOL1 = 'Y';
You should also be able to map a boolean Ebase form field to a database column of type boolean/bit/short/int and read the database value and display it automatically as a checkbox.

Regards
Jon
0 x

alexmcclune
Ebase User
Posts: 95
Joined: Wed Feb 27, 2013 5:16 pm

#3

Postby alexmcclune » Thu Aug 28, 2014 12:53 pm

Thanks Jon, it was a simple as that.

Using varchar database resource and boolean value within ebase and it works well. Thanks.
0 x


Who is online

Users browsing this forum: No registered users and 22 guests