B4J Question How to get value of a checkbox in a Websocket app

B4JExplorer

Active Member
Licensed User
Longtime User
Hi,

I have a web app which uses only edit boxes and buttons. No problems manipulating any of them.


But I can't figure out how to declare an element, and then connect it with a checkbox from the html, and then retrieve the checked/unchecked value.


Yes, I've searched the forum, and looked at some samples. There are several examples of checkboxes, but most of them are not in an html context. There are some checkbox references in some of the examples, but they all seem to be retrievable in an array rather than direct clear assignments, and anyway won't compile with 4.01.

Haven't been at it too long, just a few hours, but that's time enough to send out the SOS.

Are there any snippets that retrieve the checked/unchecked value of a checkbox, so it can be used as part of an if...then condition?
 

B4JExplorer

Active Member
Licensed User
Longtime User
Hi,

I have a web app which uses only edit boxes and buttons. No problems manipulating any of them.


But I can't figure out how to declare an element, and then connect it with a checkbox from the html, and then retrieve the checked/unchecked value.


Yes, I've searched the forum, and looked at some samples. There are several examples of checkboxes, but most of them are not in an html context. There are some checkbox references in some of the examples, but they all seem to be retrievable in an array rather than direct clear assignments, and anyway won't compile with 4.01.

Haven't been at it too long, just a few hours, but that's time enough to send out the SOS.

Are there any snippets that retrieve the checked/unchecked value of a checkbox, so it can be used as part of an if...then condition?


Got it. Same as any other JQuery element. Dim a Jquery chk_box, a corresponding future, and in this case set the future to chk_box( "checked" )

Later check for the value of that future, same as an editbox or any other html component that JQuery supports. In the case of a checkbox, this value will be true or false.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Got it. Same as any other JQuery element. Dim a Jquery chk_box, a corresponding future, and in this case set the future to chk_box( "checked" )

Later check for the value of that future, same as an editbox or any other html component that JQuery supports. In the case of a checkbox, this value will be true or false.
Hopefully this will work in ABMaterial since I have not tested it yet - but shall, since many pages need to show a checked value.
I spent many days trying to figure out how to set a checkbox "checked" (from a table setting) in JS and never did find a solution... drove me mad!
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
Hopefully this will work in ABMaterial since I have not tested it yet - but shall, since many pages need to show a checked value.
I spent many days trying to figure out how to set a checkbox "checked" (from a table setting) in JS and never did find a solution... drove me mad!

If you need more specifics, let the forum know, I'll forward more detail.
 
Last edited:
Upvote 0
Top