I'd like to make a simple interface for making SQL SELECT query for smaller number of columns from a database with lot of columns in Mathematica.
I've got my List of column names, for example:
dbColumnNames={"name1","name2","name3",...."nameN"}
What I would like to do is to have a checkbox for each element of this list named the same as elements of the list, and when checked that I get list with column names checked.
For example, I click on "name1", "name50", "name74", the list should look like:
selectedNames={"name1","name50","name74"}
If I had that list, it's easy to make an SQL query string.
The <input type="checkbox"> defines a checkbox. The checkbox is shown as a square box that is ticked (checked) when activated. Checkboxes are used to let a user select one or more options of a limited number of choices. Tip: Always add the <label> tag for best accessibility practices!
Using JavaScriptCreate multiple checkboxes and add class="checkoption" to all checkboxes. Define onclick event on the checkboxes that calls checkedOnClick(this); . Create checkedOnClick() function. Select all checkboxes where class="checkoption" and assign to checkboxesList variable.
Look at the help for CheckboxBar
and TogglerBar
.
Here is a working example:
dbColumnNames = {"name1", "name2", "name3", "name4", "name5", "nameN"};
TogglerBar[Dynamic[selected], dbColumnNames]
Click the ones you want to select, then evaluate:
selected
To see the current value of that symbol. The symbol name selected
is arbitrary.
If you have long names, you may prefer:
CheckboxBar[Dynamic[selected], dbColumnNames, Appearance -> "Vertical"]
If you have a lot of column names, you may prefer:
TextCell[
TogglerBar[Dynamic[selected], dbColumnNames, Appearance -> "Row"],
LineIndent -> 0
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With