Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manipulate, checkboxes from the list

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.

like image 409
enedene Avatar asked Oct 20 '11 18:10

enedene


People also ask

How do you make a checkbox list in HTML?

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!

How do I select one checkbox from multiple checkboxes in HTML?

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.


1 Answers

Look at the help for CheckboxBar and TogglerBar.

Here is a working example:

dbColumnNames = {"name1", "name2", "name3", "name4", "name5", "nameN"};
TogglerBar[Dynamic[selected], dbColumnNames]

Mathematica graphics

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"]

Mathematica graphics

If you have a lot of column names, you may prefer:

TextCell[
 TogglerBar[Dynamic[selected], dbColumnNames, Appearance -> "Row"],
 LineIndent -> 0
]
like image 113
Mr.Wizard Avatar answered Oct 11 '22 19:10

Mr.Wizard