samedi 16 avril 2016

Sum of multiple selected checkboxes in JAVA

If I use the "+ " sign it will just concatenate the values, but I need to find the mathematical values. I need to insert the quantity of a product. How to find the sum when multiple checkboxes are selected? I have tried this which concatenates.. Also the values need to go into the database, it is working with the concatenated values..

                 if(chckbx1.isSelected()){
                    qty= chckbx1.getText();
                    chckbx1.setSelected(true);
             }

             if(chckbx1.isSelected() && chckbx5.isSelected()){
                    qty= chckbx1.getText() + chckbx5.getText();
                    chckbx5.setSelected(true);
                    chckbx1.setSelected(true);
             }

Aucun commentaire:

Enregistrer un commentaire