mercredi 28 février 2018

Html.CheckBoxFor somehow save state through two request

Actually i'm developing new asp.net mvc app in most like qustionare. But while developing i came across an issue. I created action method which renders questions one by one depending on passed questionId. So when i try to render next question, my Html.CheckBoxFor somehow remember state of previous question and just left the same state independently from real value. Does anybody experienced such error? Thanks




Checkboxes value not saving after refresh (joomla)

I just want to finger out why the checkboxes value are not saving. So basically it's a question in what condition the goods are.

  • Bad
  • Good
  • New condition

The platform i use is joomla. The Database field (image)

<input autocomplete="off" type="checkbox" name="condition" value="Bad" <?php  if($this->item->condition_bad==1 && $this->item->id>0)?> />
    <span>Bad</span>

    <input autocomplete="off" type="checkbox" name="condition" value="Good" <?php  if($this->item->condition_good==1 && $this->item->id>0)?> />
    <span>Good</span>

    <input autocomplete="off" type="checkbox" name="condition" value="New" <?php  if($this->item->condition_new==1 && $this->item->id>0)?> />
    <span>New</span>




how to get checked of checkbox from other class?

I have a checkbox in Setting.class:

Checkbox checkBoxFlash = findViewById(R.id.checkBoxFlash);
if(checkBoxFlash.isChecked()) {
        checkBoxFlash.setChecked(mPrefe.getBoolean(KEY_CHECKED_FLASH, true));
    }else{
        checkBoxFlash.setChecked(mPrefe.getBoolean(KEY_CHECKED_FLASH, false));
    }

checkBoxFlash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if(compoundButton.isChecked()){
                myEditor.putBoolean(KEY_CHECKED_FLASH, true);
                myEditor.apply();
            }else{
                myEditor.putBoolean(KEY_CHECKED_FLASH, false);
                myEditor.apply();
            }
        }
    });

and I have a ImageButton in Main.class:

ImageButton imgStart = findViewById(R.id.imageButtonStart);
imgStart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean checked = ((CheckBox) view).isChecked(); //error in here

            switch (view.getId()) {
                case R.id.checkBoxFlash:
                    try {

                        mCameraId = mCameraManager.getCameraIdList()[0];
                    } catch (CameraAccessException e) {
                        e.printStackTrace();
                    }
                    if (checked) {
                        turnOnFlash();
                    } else {
                        turnOffFlash();
                    }
                    break;

I got an error in

                boolean checked = ((CheckBox) view).isChecked();
// java.lang.ClassCastException: android.support.v7.widget.AppCompatImageButton cannot be cast to android.widget.CheckBox

Why can not I declare it? and Can I know how to check it in Main.class? My purpose is click ImageButton it will perform function of checkbox! Thanks for a questions! (sorry if i'm wrong english grammar)




Click event on checkbox not handled because of CSS animation

I have an input and a checkbox, when the input is focused it display some information under it.

The problem is : when those information are displayed if I click on the checkbox it hides the information (because my input is not focused anymore) but the checkbox is not checked.

Here is a working plunker which reproduce this behavior.

Is there a way to make the checkbox checked in this scenario ?




Loop through checked checkboxes in grid and get labrl values WPF c#

i have a grid,inside that grid there's a stackpanel inside which there is one checkbox and 2 TextBlocks. The XAML is :

  <Grid x:name= "Maningrid" >
    <Stackpanel x:name="panel1">
       <Checkbox height="10" widht="10"/>
       <Textblock x:name="name1" text="a"/>
       <Textblock x:name="name2" text="b"/>
       <Textblock x:name="name3" text="c"/>
     </Stackpanel>
   </Grid>

Now, the thing is, inside MainGrid, i am dynamically adding panel1(the stackpanel) based on a list of random text.Anyway, what i want is , when i check the checkbox, the releavent Stackpanel(panel1)'s textblock values(name1,name2,name3's values) would be passed to a List(Of string) from where i can get the values of the three textblocks of each checked Checkboxes in stackpanels...Somewhat like the datagrid/datagridview(winforms) ..

I beg ur pardon if i failed to describe my wants properly but i hope u can understand what i'm looking for. I found this but as my motive and situation is entirely different, i can't really make use of the answer in that post...Any help/explanation of my idea ?




mardi 27 février 2018

undefined offset in laravel

Here am getting offset while one of the checkbox gets unchecked,here is the checkbox list

<input type="checkbox" id="day_off_1" name="day_off[]" checked  value="1" class="switch-input day_off">
<input type="checkbox" id="day_off_2" name="day_off[]" checked  value="1" class="switch-input day_off">
<input type="checkbox" id="day_off_3" name="day_off[]" checked  value="1" class="switch-input day_off">

Here is my controller code

$off = (!empty(Input::get('day_off'))) ? Input::get('day_off') : 0;

i tried to use isset in place of !empty but not getting allowed to use that,here if checked i want the value 1 to be stored otherwise 0




Excel 2016 - How to fill one cell with data from multiply checkboxes?

For starters, im not very great or smart when it comes to Excel. So forgive me my question, since it might be really easy, but i just cant get it to work.

I have look though google and cant seem to find a solution for this, or anything that can help me in the right direction.

I have a list of checkboxes in excel, from D4 to D27.
I have every value of the checkboxes on E4 to E27 (TRUE or FALSE).

Then i have a cell that should get the data from the checkboxes, when they are TRUE. This is B27.

B27 have a =IF(E4=TRUE; "YaY"; "Nope") script at the moment. And this is working. BUT, i cant get anymore IF statements in there, or nest them when it comes to text. I might be doing it wrong though, i dont know. -Yes i did try and look it but, but cant get it to work.

Every checkbox has diffrent data linked to it, so if D4 is checked, then the value need to be sent to B27, with text YAY!. And then if D5 is checked, it sends the data to B27 with some other data, lets say WOO!. So B27 should be looking like this : YAY!; WOO!;

|------------------------------------------------------|
|-------D4---------|----------E4--------------------|
|-------X-----------|---------TRUE----------------|
|-------X-----------|---------TRUE----------------|
|-------B27--------|---------YAY!; WOO!;-------|
|------------------------------------------------------|

How can i get this done?

I have tried to look at Macro scripting as well, but that was a great failure.

Can someone show me in the right direction, or help me out how this can be done?




ASP.NET/C#: Retrieving listview value and passing to C# via a checkbox

I've seen various solutions to this on here, but for some reason it isn't working for me. Basically on the client side I'm generating Listview elements from a database and want to retrieve the value generated in the "catlbl" label value and pass to C# to add to an "int total variable", which already has a value in it when the page is generated. Here is my ASP.NET code:

<asp:ListView ID="elecMod_listview" runat="server" DataSourceID="elecModule_sqlDataSource">
     <ItemTemplate>
          <tr>
             <td>
                <asp:Hyperlink ID="elecModuleDesc_hyperlink" runat="server" CssClass="pull-left" Text='<%# string.Concat(Eval("code"), " - ", Eval("name"))%>' NavigateURL='<%# "student_module_info.aspx?searchquery=" + Eval("code")%>' />
             </td>
             <td>
                 <asp:Label ID ="cat_lbl" runat="server" Text='<%# Eval("catPoints") %>'></asp:Label>
             </td>
             <td>
                <asp:Label ID="semester_lbl" runat="server" Text='<%# Eval("semesterNum") %>'></asp:Label>
             </td>
             <td>
                <asp:CheckBox ID="elective_checkbox" runat="server" CssClass="pull-left" OnCheckedChanged="elective_checkbox_CheckedChanged" AutoPostBack="true"/>
             </td>
           </tr>
       </ItemTemplate>
</asp:ListView>

Here is my label code:

<div class="row mt">
   <div class="col-sm-12 col-md-12 col-lg-12">
      Total CAT Points Selected: <asp:Label ID="catTotal_lbl" runat="server" Text="" />
   </div>
</div>

And now here is my C# code:

//This value will be changed upon Page Load via other parts in the code and is displayed in the "catTotal_lbl" 
int total = 0; 
protected void elective_checkbox_CheckedChanged(object sender, EventArgs e)
{
    foreach (ListViewDataItem row in elecMod_listview.Items)
    {
        CheckBox catCheck = (CheckBox)row.FindControl("elective_checkbox");
        if(catCheck.Checked)
        {
            int elecCat = Convert.ToInt32(((Label)row.FindControl("cat_lbl")).Text);

            total += elecCat;
        }
    }

}

When I check the box, nothing happens. I basically want the value from "catPoints" added to the "catTotal_lbl" whenever I check the checkbox(s) and then stick that value in a database via C#. Been racking my brains on this for awhile! I'm still a newb so apologies if I broke any protocol.




Using check boxes to insert data into a database with a text box

I want to insert data selected from check boxes into a database as well as text which the user types into a text box. I want both the check box values and the text to go into the same row on my database.

My code for abc.php:

 <div class="container">
  <h2>Please select the answer below:</h2>
  <form>

    <div class="checkbox">
      <label><input type="checkbox" name="response" value="A">A</label>
    </div>
    <div class="checkbox">
      <label><input type="checkbox" name="response" value="B">B</label>
    </div>
    <div class="checkbox">
      <label><input type="checkbox" name="response" value="C">C</label>
    </div>





<form method="post" name="input" action="insert.php" >
Question ID: <input name="questionid" type="text"/><br/>
<input type="submit" name="Submit" value="insert" />
</form>

my code for insert.php

if(isset($_POST["response"]))
{


    $query = "INSERT INTO response (student_id, response, question_id) VALUES (:studentID, :response, :questionid)";
    $statement = $conn->prepare($query);
    $statement->execute(
      array(
        ':response' => $_POST["response"],
        ':studentID' => $_SESSION['studentid'],
        ':questionid' => $_POST["questionid"]

      )
        );

}

When i press the insert button, nothing happens..... can anyone help?




lundi 26 février 2018

Validate dynamic checkbox

I have two tables in the database, Table A and Table B. User fill up Form A that will insert new record in Table A. In Form B, the records in Table A are called as checkbox. From this form, the data will be inserted into Table B. The following code are in Form B. The data captured in this code will be inserted into a column (let say column name is menu_check), resulting something like "value1,value2,value3" (depending on how many checkbox the user check)

<input type="checkbox" name="chckmenu" id="chckmenu" value="#qMenu.menu_id#"   />#qMenu.menu_name_eng#

After Form B is complete, user will be directed to a page where shows the list of all records in Table B. From this table, user can edit any records. Something like a simple listing where the user can view, update or delete any records. In the edit page, how to call out the value of menu_check, and see if any checkbox are checked or not based on the column.

For example; If value in menu_check is 'value1,value2,value3', only the first, second and third checkbox are checked. If value in menu_check is 'value1,value3', only first and third checkbox are checked.




How to uncheck a group of checkbox in JQuery/JavaScript

I'm trying to keep either "All" and a group of checkboxes (1,2,3) is unchecked. For example, when "All" and "1" are checked, if I click "All", "1" should be unchecked, and vice versa.

<input type="checkbox" name="checkAll" class="selectAll" />  All  <br/>
<input type="checkbox" name="checkuser" class="cb_box "  />  1
<input type="checkbox" name="checkuser" class="cb_box "  />  2
<input type="checkbox" name="checkuser" class="cb_box "  />  3

I tried in this way but it doesn't work. Any suggestion?

$(function(){ $('.selectAll').click(function(){ $('input[name=checkuser]').attr('unchecked', $(this).attr('checked')); });




Implement bootstrap 4 checkboxes style in yii\grid\CheckboxColumn

I'm using bootstrap 4 and YII 2 and i want to customize my checkbox inputs like the next link

https://getbootstrap.com/docs/4.0/components/forms/#checkboxes.

So im usign the yii\grid\CheckboxColumn class, but I dont know how to do it.

I tried the fallowing

'columns' => [
            [
                'class' => 'yii\grid\CheckboxColumn',
                'cssClass' => 'checkbox-select',
                'headerOptions' => ['style' => 'width:5px'],
                'header' =>  '<div class="custom-control custom-checkbox">'.Html::checkBox('selection_all', false, ['id' => 'customCheck1', 'type' => 'checkbox', 'class' => 'custom-control-input select-on-check-all']).'<label class="custom-control-label" for="customCheck1"></label></div>',
                'checkboxOptions' => function($model){

                    return ['<div class="custom-control custom-checkbox">'.Html::checkBox('selection', false, ['id' => "'customCheck".$model->id."'", 'class' => 'custom-control-input']).'<label class="custom-control-label" for="customCheck'.$model->id.'"></label></div>'];

                },

            ],
           ],

It only works in the table header but not in the other checkboxes.

enter image description here




Dropdown Checkbox Closes when Item Checked, and Doesn't Save Selection

I'm new to Javascript and AngularJS, and currently trying to implement a dropdown checkbox via a button (For a search filter). I currently am able to have the dropdown appear, but when I check a checkbox, the dropdown immediately closes. The checked item is also not saved as checked when I open the dropdown again. Here's what I have in my tpl.html:

<div class="input-group-btn">
     <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" bs-dropdown data-template-url="dropdown-template" data-placement="bottom-right">
        <span class="fa fa-filter"></span>
     </button>

     <li class="dropdown-filter">
        <script type="text/ng-template" id="dropdown-template">
            <ul class="dropdown-menu">
                <div>
                   <input type="checkbox" id="disabledStores">
                   <label for="disabledStores">Show Disabled Stores</label>
                </div>
            </ul>
        </script>
     </li>
</div>

What am I doing wrong?




Scrollable Checkbox Canvas Within Main Python Frame

I'm working on creating a GUI for a small application, and it being my first endeavor into Python GUI I'm a bit overwhelmed. My goal here, is to create a GUI that has some buttons and entry fields and a progress bar in it, and also in that same frame, have a canvas (or frame? not sure) that has a vertical scrollbar in it so that I can populate that canvas with checkboxes and be able to scroll the list within the main window.

I've got pretty much everything laid out, but without the scrollable canvas inside the frame, I'm at a bit of a standstill. Is there a way I can implement this into what I've already got here?

class MainWindow(Frame):

def __init__(self):
    Frame.__init__(self)
    self.master.title("WIP")
    # self.master.minsize(0, 0)
    self.grid(sticky=E+W+N+S)
    self.columnconfigure(1, weight=1)

    self.var_det = IntVar(self)
    self.inputtext = StringVar()
    self.outputtext = StringVar()
    self.lastknowninput = StringVar()
    self.lastknownoutput = StringVar()
    self.defaultDir = "\\"
    self.currentInputDir = ""
    self.currentOutputDir = ""

    scroll = Scrollbar(self)

    self.pbar_det = ttk.Progressbar(self, orient="horizontal", length=750, mode="determinate", variable=self.var_det, maximum=100)
    self.pbar_det.grid(row=15, column=0, pady=2, padx=2, sticky=E+W+N+S, columnspan=5)

    Button(self, text="Browse", command=self.open_inputdir).grid(row=0, column=3, pady=2, padx=2, sticky=E+W+N+S)
    Button(self, text="Browse", command=self.open_outputdir).grid(row=1, column=3, pady=2, padx=2, sticky=E+W+N+S)



    canvas = Canvas(self, yscrollcommand=scroll.set).grid(row=2, column=0, padx=2, pady=2, sticky=E+W+N+S, columnspan=3, rowspan=10)



    # Need to add function to set all checkboxes state to checked
    Button(self, text="Select All").grid(row=4, column=4, pady=2, padx=2, sticky=E+W+N+S)
    Button(self, text="Select None").grid(row=6, column=4, pady=2, padx=2, sticky=E+W+N+S)

    # Need to add function to call main python file, also to increment values to control progressbar as well as progress text
    Button(self, text="Run", command=self.doStuff).grid(row=8, column=4, pady=2, padx=2, sticky=E+W+N+S, rowspan=2)
    Button(self, text="Cancel", command=self.stopStuff).grid(row=10, column=4, pady=2, padx=2, sticky=E+W+N+S, rowspan=2)

    # Can perform inputfile.get() to pull off value inside of inputfile entry field
    input = Entry(self, textvariable=self.inputtext).grid(row=0, column=1, pady=2, padx=2, sticky=E+W, columnspan=2)
    output = Entry(self, textvariable=self.outputtext).grid(row=1, column=1, pady=2, padx=2, sticky=E+W, columnspan=2)

    Label(self, text="Module Progress Text Here").grid(row=13, column=0, pady=2, padx=2, sticky=W, columnspan=5)
    Label(self, text="Input File Path").grid(row=0, column=0, pady=2, padx=2, sticky=W)
    Label(self, text="Output File Path").grid(row=1, column=0, pady=2, padx=2, sticky=W)

def open_inputdir(MainWindow):
    if not MainWindow.inputtext.get():
        MainWindow.inputfilename = filedialog.askdirectory(initialdir="\\", title="Select Folder")
        if MainWindow.inputfilename:
            MainWindow.inputtext.set(MainWindow.inputfilename)
            MainWindow.lastknowninput.set(MainWindow.inputfilename)
    else:
        MainWindow.inputfilename = filedialog.askdirectory(initialdir=MainWindow.currentInputDir, title="Select Folder")
        if MainWindow.inputfilename:
            MainWindow.inputtext.set(MainWindow.inputfilename)
            MainWindow.lastknowninput.set(MainWindow.inputfilename)

def open_outputdir(MainWindow):
    if not MainWindow.outputtext.get():
        MainWindow.outputfilename = filedialog.askdirectory(initialdir="\\", title="Select Folder")
        if MainWindow.outputfilename:
            MainWindow.outputtext.set(MainWindow.outputfilename)
            MainWindow.lastknownoutput.set(MainWindow.outputfilename)
    else:
        MainWindow.outputfilename = filedialog.askdirectory(initialdir=MainWindow.currentOutputDir, title="Select Folder")
        if MainWindow.outputfilename:
            MainWindow.outputtext.set(MainWindow.outputfilename)
            MainWindow.lastknownoutput.set(MainWindow.outputfilename)

def doStuff(MainWindow):
    MainWindow.pbar_det.start()

def stopStuff(MainWindow):
    MainWindow.pbar_det.stop()
    MainWindow.var_det.set(0)

def set(self, val):
    self.var_det.set(val)


if __name__ == "__main__":
            MainWindow().mainloop()

Here's a snip from what I've got generating right now, the large open space is where the canvas has created, but I'm haven't been able to get scroll to appear in it so far.

Current State

Help is greatly appreciated!




TreeView setOnEditCommit trouble

I've got some problems with setOnEditCommit TreeView method. So here's my code

public class MyCheckBoxTreeViewConsulter extends TreeView {

public MyCheckBoxTreeViewConsulter() {
    super();
    this.setEditable(true);

    this.setCellFactory(CheckBoxTreeCell.<ChampBdd>forTreeView());

        this.setOnEditCommit(e -> {
            System.out.println("hi");
        });
}}

I have a result like this

https://imgur.com/a/zQmwH

Whenever I double click on one of theses row, nothing happens.

I want this kind of result to edit data

https://imgur.com/a/0rJ8F

Any thoughts on this ?

Feel free to ask more of my code if you need it.




How to style a checkbox nested within a label tag

I usually use the following when setting up a checkbox:

<input ....>
<label for="...">Lorem ipsum</label>

I use the standard method of styling label::before to simulate a style for my checkbox depending on whether the checkbox has been checked or not:

input label{....}
input::checked label{....}

However, a Wordpress plugin is forcing me to use the following syntax:

<label>....
    <input....>
</label>

As CSS in unable to traverse the DOM, my usual pure CSS method won't work here.

Any other suggestions? Perhaps jQuery? Or is there a pure CSS solution I'm missing?

Thanks for any help.




Knockout.js: disable other checkboxes when one checkbox is selected

I'm new with Knockout and I'm struggling with the following issue.

I have made some product divs that are clickable (with a hidden checkbox). If someone clicks on a div, a hidden checkbox is selected and the style changes.

Now I want to add dependencies, as some products cannot be ordered simultaneously. I want to do this based on the checkbox value (true/false). So let's say, if product 1 is selected, product 2 and 3 should be disabled with an additional class "disabledDiv". However, this event change binder does not do the trick for me. I doesn't even fire an alert.

self.valueCheckboxChanged = function() {
  alert('value has changed')
}

Can someone please help me, I'm at a loss. I made a simplified JSFiddle (https://jsfiddle.net/Seabiscuito/f1qnr8a2/) to illustrate the problem.




Check-All checkbox do not change the ng-model

I used this jquery for a check-all checkbox that when clicked all of the checkboxes will be ticked:

function checkAll(e) {
    var check = $(e).is(':checked');
    if (check) {
        $('[name="row_Checkbox"]:not(:checked)').trigger('click');
    }
    else {
        $('[name="row_Checkbox"]:checked').trigger('click');
    }
}

But it has a problem, I set the angular function for ng-click of checkboxes that changing ng-model according to the some condition, and if selected checkboxes more than a number the ng-model becoming null, it is working when I click checkboxes individually but when I am using check-all checkbox that ng-model do not becoming null and still has a value!!!

I tried various solutions, but any of them has a same result.

What is going wrong???




Adding checkbox table header using in grid layout eclipse SWT

I have and existing table and would like to add check box to the header of the table. The existing table is using GridLayout and GridData. But now I need to introduce a check box in table header column. When a user selects that checkbox all the rows in a table should to be seleted. To achieve this I achieved with the help of two images (checked image and un-checked image). Here I am able to achieve the funnctionality but the problem is that if I click exactly on the images the listener is not getting invoked. If I click beside the images then the functionality is working as expected.

Now I would like to try without those static images. And by default I need to show all the check boxes cheked on startup.




dimanche 25 février 2018

HTML/CSS - Removing wrapping with checkboxes/labels

I have the following HTML and CSS: jsfiddle.net/s1mjdy4e/8/

The issue is that the text is wrapping down. How can I have the text not wrap and stay on one line?




How to delete record from database with checkbox in telerik radgridview C#

I want to delete record from database with checkbox in telerik radgridview ... Please Help Me! Thanks




Checkboxes not showing in html using symfony 4

I'm trying to show checkboxes in a form using symfony 4. I used the same information found on the symfony 4 documentaion Even though they are taken into account when clicking on the label (saved in the DTB) they don't render on the html.

Here's an example of one of the options of the form using a checkbox:

->add('accessibility', CheckboxType::class, [ 'label' => 'Accéssibilité', 'required' => false, ])

however here is the rendering on my page : No checkbox

Let me know if you need any other information, thanks for the help




samedi 24 février 2018

C#: Check boxes

I have 4 check boxes. One or all can be selected for the program to do its thing. Right now I only have if statements for when only one of them is selected. if I were to do if statements for all situations, I will need 24. Is there an easier way?




Check box that creates nested objects in rails

I'm building an app that creates exams. For the part where a user selects the answers on the exam, I want to use a checkbox (or a radio button) to allow them to pick the answer.

I want all the user-selected answers to be a table in itself called "responses". I can't figure out how to use a radio button to create records.

All the response record needs to do is take the ID's of the Exam, User, and Score. Score is a table that tracks the user's scores and the number of correct answers. Here's my examination model (rails wouldn't let me use the word "exam"). I have it set for nested attributes.

class Examination < ApplicationRecord
  belongs_to :user
  has_many :questions, dependent: :destroy
  has_many :scores
  has_many :responses
  has_secure_password

  accepts_nested_attributes_for :responses, allow_destroy: true
end

The response model is pretty basic:

class Response < ApplicationRecord
  belongs_to :user
  belongs_to :score
  belongs_to :examination
end

Here's the "take an exam" page: <%= link_to "Back to all exams", examinations_path %>

<h2><%= @exam.name %></h2>
<h3><%= @exam.intro %></h3>

<%= form_for @exam  do |f| %>
  <%= f.hidden_field :name, value: @exam.name  %>
  <%= fields_for :responses do |res_f| %>
    <% @exam.questions.each_with_index do |question, i| %>
      <% index = i + 1 %>
      <h2>Question #<%=index%></h2><span style="font-size: 24px; font-weight: normal">(<%= question.points %> Points)</span>
      <hr>
      <h3><%= question.body %></h3>
      <% question.answers.each do |ans| %>
        <table>
          <tr>
            <td><%= res_f.check_box :answer_id , ans.id, :examination_id , @exam.id, :user_id  %></td>
            <td><%= ans.body %></td>
          </tr>
        </table>
      <% end %>
    <% end %>
  <% end %>

  <%= f.submit 'Submit' %>
<% end %>

This code doesn't run because Rails expects the responses records to exist in order to use the form. It throws this error:

undefined method `merge' for 484:Integer

If I tweak that checkbox code to this:

<%= res_f.check_box :answer_id  %>

The code will run and it will give me the following params on submit:

Started PATCH "/examinations/34" for 127.0.0.1 at 2018-02-24 16:22:41 -0800
Processing by ExaminationsController#update as HTML
      Parameters: {"utf8"=>"✓", "authenticity_token"=>"y4vcPByUKnDdM6NsWDhwxh8MxJLZU4TQo+/fUrmKYEfb3qLn5FVieJAYirNRaSl0w5hJax20w5Ycs/wz1bMEKw==", "examination"=>{"name"=>"Samuel Smith’s Oatmeal Stout"}, "responses"=>{"answer_id"=>"1"}, "commit"=>"Submit", "id"=>"34"}

I know it's not right but I was hoping it would create a record at least. All the checkbox has to do it create a response record. It should be able to grab the answer_id, exam_id and user_id. That's it.

Does anyone know how to do this?




itext - pdf checkbox filled differently

I have a pdf fillbale form with a checkbox in it. If i use the acrobat reader, the checkbox is filled like this checkbox filled by acrobat

but, if i use itext 5.5.13, the checkbox is filled like the the one below. checkbox filled by itext

the way the checkbox filled is different across acrobat and itext. is there a way to make the itext fill the checkbox similar to acrobat and make it bold.

I'm using the following code to fill the checkbox.

PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
AcroFields form = stamper.getAcroFields();

form.setField("cb1", "Yes");

stamper.setFormFlattening(true);
stamper.close();

Thanks.




Trouble designing and saving layout with checkboxes programatically

I'm a beginner android developer. I am creating an app but having trouble to get a rough outline for my next task which I am going to explain below. I am not asking for code. I just want to know the best way to do the below.

I have an Activity that displays a RecyclerView with a list of items like this:

enter image description here

My question is related to the 3 checkboxes.

  • How should I approach creating the layout in the pic? Do I have to include 3 checkboxes and 3 booleans in my main object class? The other items in the object class are saved in SQL database and the RecyclerView in the activity gets its data from there using a cursor. Can the value of the checkboxes be retrieved using the cursor?

  • Do I create a separate sparseBooleanArray for the checkboxes? Do I create a HashMap for them?

  • Should I store the value of the checkboxes (Checked/Not Checked) in SQL or SharedPreferences?




Disable GtkMenu deactivation upon item activation

As I use GtkCheckMenuItem, normally I wouldn't want the GtkMenu to deactivate (close/hide) itself when checking or unchecking it.

How do I prevent this unwanted behavior?




vendredi 23 février 2018

Prestashop 1.6 how make - add to compare on checkbox?

What i know, it just code in product-list.tpl and in products-comparitions.js there are action on class "add_to_compare"

<div class="compare">
  <a class="add_to_compare" href="{$product.link|escape:'html':'UTF-8'}" data-id-product="{$product.id_product}">{l s='Add to Compare'}</a>
</div>

I need checkbox instead icon plus/minus




Php checkboxes to rows

I need to insert each checkbox to row in MySql.

At the moment i am able to catch only one Checkbox, but i usaly have them 1 - ... who knows how many..

All my checkboxes come from Db like that :

<input type="checkbox" name="lisateenus[]" value="<?php echo $row["id"]; ?>">

On insert it should take the "page id" what is created and after that insert checkbox values to table.

it gets all needed ID-s but it inserts only one checkbox what is checked..

         $result = mysqli_query($con,$query);
    if($result) {
            $last_id = $con->insert_id;
            $error = "Uus Teenus lisatud! ". $last_id;


            $checkBox = implode(',', $_REQUEST['lisateenus']);
            $query="INSERT INTO lisateenuse_seos (p_id, l_id, lisaja) VALUES ($last_id,'" . $checkBox . "','1')";     
            mysqli_query($con, $query) or die (mysql_error() );
            echo "Complete";


        } else {
            $error = "Teenuse lisamine ei õnnestunud";}

So everything is working exept that it only inserts one row, but 3 rows are checked and should be inserted..




jeudi 22 février 2018

Checkbox floating upwards when adding button to html

I am using pretty checkbox library and have 3 repeating elements drawn inside a React app: checkbox, its label, and React-Bootstrap Button. When I add the Button, the checkbox floats above and I am having real trouble bringing it down, centering it horizontally:

enter image description here

The part of the code that is drawing the elements is the following one:

...
<Row>
        <Col xs={2} md={2}>
          {
            this.state.allExprData.length ?
            <div>
              <Label bsStyle="primary" style = >
                <Glyphicon glyph="check"/>  Selected Genes
              </Label>
              <p></p>
            </div>
            : ""
          }
          {
            this.state.allExprData.map((geneObj, idx) => {
               return (<div key={geneObj["name"]} className={"pretty p-default p-curve"}>
                 <input type="checkbox" onChange={this.onChangeCheckbox} defaultChecked/>
                   <div className={"state p-primary"}>
                      <label style=>{geneObj["name"]}</label>
                      <Button style= bsStyle="danger" bsSize="xsmall">
                        <Glyphicon glyph="remove-circle"/> Remove
                      </Button>
                  </div>
               </div>)
            })
          }
...

I tried applying different classes (text-center, center-block, pagination-centered, etc) the way it is described in the thread:

Twitter Bootstrap - how to center elements horizontally or vertically

But no luck. Any suggestions would be greatly appreciated.




Loop to determine out come of multiple checkboxes being checked from list

I'm trying to take a list of checkboxes and create a loop that does the following: If 3 out of 5 boxes are checked then it subtracts 1 from the opponents score

If 4 out of 5 boxes are checked then it subtracts 1 from the opponents score

If 5 out of 5 boxes are checked then it subtracts 1 from the opponents score

I'm new to java and android studio. Any help would be greatly appreciated!

public class MainActivity extends AppCompatActivity {
    int scoreNearCorner = 10;`enter code here`
    int scoreFarCorner = 10;
    String wNearCorner = "W";
    String wFarCorner = "W";
    String lNearCorner = "L";
    String lFarCorner = "L";

    CheckBox chebox = (CheckBox) findViewById(R.id.checkBox);

    CheckBox chebox2 = (CheckBox) findViewById(R.id.checkBox2);

    CheckBox chebox3 = (CheckBox) findViewById(R.id.checkBox3);

    CheckBox chebox4 = (CheckBox) findViewById(R.id.checkBox4);

    CheckBox chebox5 = (CheckBox) findViewById(R.id.checkBox5);

    int count = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

public  void onCheckboxClicked(View view) {


    ArrayList checkboxes = new ArrayList(5);
    checkboxes.add(chebox);
    checkboxes.add(chebox2);
    checkboxes.add(chebox3);
    checkboxes.add(chebox4);
    checkboxes.add(chebox5);




ASP.Net MVC : Html Check box always getting false on form after submit

I am using the MVC tightly couple Html Checkboxfor , but its getting always false in my model after form post and the property is bool type.

View:

<div class="col-md-4">
        <label class="mar-t-8">KMAdministration</label>
        <div class="border-box">
            <div class="custom-checkbox mar-b-10">
                @Html.CheckBoxFor(x => x.IsKMAdministrationDone)

            </div>
        </div>  
    </div>

Controller:

    public ActionResult SaveData(ParametersModel model)
    {
     // always getting false here...
     bool val=model.IsKMAdministrationDone;
    }




ag-grid React Header Component Select all Checkbox selection not working on mobile and tablet properly

I am facing a weird issue where I am implementing Header component Select all Checkbox selection.

It's working as expected on desktop but when I am testing the same functionality on tablet or mobile the checkbox selection is working randomly.

What I mean is when i am clicking inside checkbox its not getting checked but when I am clicking some where near to left border of checkbox it is getting selected.

Below is the code for the same:

column defs:

this.setState({
      terminalAllocationsColumnDefs: [
        {headerName:"",field:"status", width:150, cellRendererFramework: CheckBoxRenderer, headerComponentFramework : HeaderCheckBoxRenderer,HeaderChangeCallback:this.headerChangeCallback},
        {headerName: this.state.multiLangMsgs.TERMINAL_ID, field: "DId", width: 250},
        {headerName: this.state.multiLangMsgs.TERMINAL_TYPE, field: "DType", width: 250},
        {headerName: this.state.multiLangMsgs.MSISDN, field:"MsId", width:260},
        {headerName: this.state.multiLangMsgs.SIM_ID, field:"SimId", width:260},
        {headerName: this.state.multiLangMsgs.SATALITE_ID, field:"DKey", width:250}
      ]
    });

HeaderCheckBoxRenderer Component

onCheckBoxChange(){
        this.selectAll = false;
        if(this.state.checkStatus == "inactive"){
            this.setState({
                checkStatus :"active"
            });
            this.selectAll = true;
        }else {
            this.setState({
                checkStatus: "inactive"
            });
        }
        // }console.clear();
        // console.log(this);
            try{
                if(this.props.column.colDef.HeaderChangeCallback){
                    this.props.column.colDef.HeaderChangeCallback(this.selectAll);
                }
            }catch(e){}
    }
    render() {
        return (
            <div class="ag-header-cell" style=padding>
                <div class="ag-header-cell-resize"/>
                <div class="ag-header-select-all"/>
                <div class="ag-header-component"/>
                <input id="checkboxMember" type="checkbox" onClick={this.onCheckBoxChange.bind(this)} className="check" checked={this.state.checkStatus == "active" ? true : false}/>
            </div>
        );
    }




Liferay CheckBox/Radio Styling

Hello I'm trying to style a Liferay Checkbox, I can't edit the HTML so I have to work straight on the CSS but I can't style it properly, in particular I found a strange behaviour on :checked selector.

This is the HTML:

<div class="checkbox">
    <label for="_com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet_INSTANCE_qaCfYGoELD8F_ddm$$CheckBoxTest$ViVemTVR$0$$de_DE">
        <input id="_com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet_INSTANCE_qaCfYGoELD8F_ddm$$CheckBoxTest$ViVemTVR$0$$de_DE" name="_com_liferay_dynamic_data_lists_form_web_portlet_DDLFormPortlet_INSTANCE_qaCfYGoELD8F_ddm$$CheckBoxTest$ViVemTVR$0$$de_DE" type="checkbox" value="true"> CheckBox Test
            <span class="icon-asterisk text-warning"></span>
    </label>
</div>

And this is my CSS:

.checkbox input[type=checkbox] {
  visibility: hidden;
}

.checkbox {
  width: 12px;
  height: 12px;
  background-color: #FFFFFF;
  border-radius: 3px;
  border: 1px solid #C6C6C6;
}

.checkbox:checked {
  background-color: blue;
  width: 12px;
  height: 12px;
  background-color: #FFFFFF;
  border-radius: 3px;
  border: 1px solid #C6C6C6;
}

Is there any work-around to handle this?




mercredi 21 février 2018

Is there any way to make this checkbox html structure as slide with pure css?

this is my first question in stackoverflow ;)

I'm using a wordpress plugin called "WooCommerce TM Extra Product Options". When I create options for any woocommerce product with checkboxes, the html that the plugin generates is exactly like the below (and the checkbox have the default appearance):

    <label for="tmcp_choice_0_0_1_1519167210">
    <input class="tmcp-field ingredientepizza tmhexcolor_0_0_1_1519167210 tm-epo-field tmcp-checkbox" name="tmcp_checkbox_0_0_1519167210" data-limit="" data-exactlimit="" data-minimumlimit="" data-image="" data-imagec="" data-imagep="" data-imagel="" data-image-variations="[]" data-price="" data-rules="[&quot;&quot;]" data-original-rules="[&quot;&quot;]" data-rulestype="[&quot;&quot;]" value=" molho de tomate_0" id="tmcp_choice_0_0_1_1519167210" tabindex="1" type="checkbox" checked="checked">
        <span for="tmcp_choice_0_0_1_1519167210"></span><span class="tc-label tm-label"> molho de tomate</span></label>

Is there any way to make a change in the following codepen CSS code (https://codepen.io/macbobbitt_/pen/BjepPG) to work with the above specific html structure (since I can't change it).

Thanks in advance for any help.




Checkbox: what value store in database?

I have a checkbox input. This by default sends value on and if it's unchecked it sends nothing. So, what value I have to store in database if it's checked and what if it's unchecked?




React Native -> How to see if checkbox is checked

Im completely new to React-Native.

For one of my projects (for school) I have to make an Geolocotion application, where they want to know the Latitude and Longitude of the current position.

Next to those two things I need to make an CheckBox for showing (or not showing) the googleapi image of the position from maps.

Everything works, but.. I can not find a correct working of the check if the checkbox is checked or not..

My code now (render (checkbox is pointed by an arrow)):

render() {
const { checked } = this.state;
return (
  <View style={styles.container}>
    <TouchableHighlight onPress={ this._getLocation} underlayColor="white">
      <View style={styles.button}>
        <Text style={styles.buttonText}>Get your Location!</Text>
      </View>
    </TouchableHighlight>
    -->--> <CheckBox label='Check to add image of location.' value={this.state.checked} onValueChange={() => this.setState({ checked: !this.state.checked })}/>
    <Text style={styles.textDefault}>Your Location.</Text>
    <Text style={styles.textDefault}>Latitude: {this.state.lat}</Text>
    <Text style={styles.textDefault}>Longitude: {this.state.long}</Text>
    <Text style={styles.textDefaultPlus}>More or less {this.state.meters} meters.</Text> 
    <Image style= source={this.state.img}></Image>
  </View>
);

My code now (if checked):

if (this.state.checked === true) {
  crdImg = {uri:'https://maps.googleapis.com/maps/api/staticmap?center=' + crd.latitude + ',' + crd.longitude + '&zoom=17&size=800x800&sensor=false'};
}
else {
  crdImg = 'Other uri, but to ong for here.'};
}

this.setState({ lat: crd.latitude, long: crd.longitude, meters: crd.accuracy, img: crdImg});

I tried: some of the answers here and This answer but, I can not get it to work as I want.

To be precise what I want:

  • If checkbox (pointed in code by an arrow) Is checked: Show image of current position from maps.

  • If checkbox is Not checked: Other image.

Anyone who can help me with this?

For questions, just ask and I will update this post if necesarry.




How to create a string with checkbox?

I'm trying to get a result that the string will turns to "The person selected 1, 2, 3."

However with the code below, if I checked all three boxes I can only generate: The person selected 1, The person selected 1, 2, The person selected 1, 2, 3,

I don't want the generated notes have 3 separate lines.

        var notes = "";
        var reason = "";
        for (j=0; j<document.reason.reasonqst.length; j++){
            if (document.reason.reasonqst[j].checked==true){
                notes += "The person selected";
                if (j==0)
                    reason += "1, ";
                if (j==1)
                    reason += "2, ";
                if (j==2)
                    reason += "3,";
                notes += "" + reason + "\r";

            }
        }



    <form id="reason" name="reason" method="post" action="">
    <table>
        <tr>        
            <td>BPC: <input onclick="ds_sh(this);" name="reason" id="reason" readonly="readonly" style="cursor: text" /><br /></td>
        </tr>
        <tr>
            <td style="width: 120px;"><input type="checkbox" name="reasonqst" id="reasonqst" />1</td>
            <td style="width: 120px;"><input type="checkbox" name="reasonqst" id="reasonqst" />2</td>
            <td style="width: 120px;"><input type="checkbox" name="reasonqst" id="reasonqst" />3</td>

        </TR>
    </table>
         </form>




delete button visible while checkbox is checked

I have table with 3 columns. The third columns is a check box for each row.

<tr id='sub".$this->getHtmlId()."_".$cpt."' class='mui-row'>
  <td class='mui-col-md-6'>".$row[0]."</td>
  <td class='mui-col-md-2'>".$row[1]."</td>
  <td class='mui-col-md-2' style='border:none'>
    <component id='box' class=\ "CheckBoxComponent\" name=\ "chk".$row[3]. "\" />
  </td>
</tr>";

what i want is that when I check a checkbox the delete button become visible and if i check a second or more it stay visible because I can delete multiple rows at the same time.

Right now, everything I have tried do that when I check a row the button appear I click a second one it disappear and when I click a third one it appear again

here some example that I tried :

$('#deleteButton').toggle('slow', function() {
  // Animation complete.
});

var chkbox = $(\".check\");
    button = $(\"#box\");
      button.attr(\"disabled\",\"disabled\");
        chkbox.change(function() {
            if (this.checked) {
              button.removeAttr(\"disabled\");
              }
              else {
                button.attr(\"disabled\",\"disabled\");
                }
              });




set checkbox and span in the same line and add a clickevent to the span

I am kind of embarrassed that I can't find a solution to this simple task.

It is easy to make a checkbox and a span-tag in the same line, which what I have done liek this:

<label class='checkbox' for='visible_1'>
    <input id='visible_1' class='visible' type='checkbox'>
    <span>Layer_1</span>
</label>

I set a function to the checkbox, which show/hide the layer_1 and works pretty good. I also set a event with jQuery to the span-tag, which show some text in the website, but then I got a problem, I can't "touch" the text of span, the checkbox kinda of blocks the text, no matter where I click, as long as I click in the line, which checkbox and span are in, I can only select the checkbox.

It seems like the checkbox takes the whole line and the click event on span-tag is blocked by checkbox.

I don't know how it can be done, cause I don't want the checkbox to take a line and the span-tag another, it's even worse.




mardi 20 février 2018

What controller even to use?

I am using a ComboBox and a Panel. What I want to do is when I click on the ComboBox, the Panel would appear.

The problem is, I want to still be able to activate a CheckBox inside the Panel but the ComboBox and Panel would be close together once I lose focus.

Is there a possible way to do this?

My temporary solution is this:


panelCol.MouseLeave += (s, e) =>
{
  panelCol.Visible = false;
};

tp.Click += (s, e) =>  //tp is a tabPage.
{
  panelCol.Visible = false;
};

dataGridView.Click += (s, e) =>
{
  panelCol.Visible = false;
};


enter image description here




Check boxes and instant output to separate text box and clipboard

In this example (a-star.dk) the user can compose text by selecting different check boxes - the choices are instantly written to the textbox (for COUNTRY at least). But I have problems integrating line 2-3-4 (CAPITAL, COLOR, NUMBER) in the same output textbox, how can this be done? So at final all information from the checked boxes are written in the outbox, but each section (1-2-3-4) starting at a new line.

Secondly, I want to paste/copy/cut the final result in the text box to the clipboard (equals Ctrl+C) so it can be used in other software. Im using clipboard.min.js but it does not seem to work, what is wrong?

Thirdly, thus not very important, is it possible to remove the first autogenerated "," from each section? (how?) so that the final result would be: [COUNTRY: America, Burma, Chile,] and not [COUNTRY:, America, Burma, Chile,]

Fourthly, how can I integrate user input (line 4 - NUMBER - Other number) numbers or text? in the array and thus in the final output

<!doctype html>
<html><head><meta charset="UTF-8"><title>TEST</title>
<script src="clipboard.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("input[name='A']").change(function(){
      var checkedCountries = $("input[name='A']:checked");
      var countries = [];
      for(var i = 0; i<checkedCountries.length; i++) {
          countries.push(checkedCountries[i].value + ",");
      }
      $("#countryList").val(countries.join(" "));

  });
  $("#copyBtn").click(function() {
      var copyText = document.getElementById("countryList");
      copyText.select();
      document.execCommand("Copy");
      alert("Copied the text: " + copyText.value);
  });
});
</script>
<script>function changeText(){
var userInputA = Array.prototype.slice.call(document.querySelectorAll(".A:checked")).map(function(el) {return el.value;}).join(', ')
var userInputB = Array.prototype.slice.call(document.querySelectorAll(".B:checked")).map(function(el) {return el.value;}).join(', ')
var userInputC = Array.prototype.slice.call(document.querySelectorAll(".C:checked")).map(function(el) {return el.value;}).join(', ')
var userInputD = Array.prototype.slice.call(document.querySelectorAll(".D:checked")).map(function(el) {return el.value;}).join(', ')


document.getElementById('output1').innerHTML = userInputA;
document.getElementById('output2').innerHTML = userInputB;
document.getElementById('output3').innerHTML = userInputC;
document.getElementById('output4').innerHTML = userInputD;

return false;
}

</script>

<script>
new Clipboard('.btn');
</script>

</head><body>


<form method="get" onsubmit="return changeText()">

<table style="background-color:white;">

<tr><td style="background-color:#EFEFFB;"><input type="checkbox" name="A" class="A" value="COUNTRY:">COUNTRY:</td><td style="background-color:#EFEFFB;">
<input type="checkbox" name="A" class="A" value="America">America
<input type="checkbox" name="A" class="A" value="Burma">Burma
<input type="checkbox" name="A" class="A" value="Chile">Chile
<input type="checkbox" name="A" class="A" value="Denmark">Denmark
<input type="checkbox" name="A" class="A" value="England">England
</td></tr>

<tr><td style="background-color:#EFEFFB;"><input type="checkbox" name="B" class="B" value="CAPITAL:">CAPITAL</td><td style="background-color:#EFEFFB;">
<input type="checkbox" name="B" class="B" value="Amsterdam">Amsterdam
<input type="checkbox" name="B" class="B" value="Berlin">Berlin
<input type="checkbox" name="B" class="B" value="Copenhagen">Copenhagen
<input type="checkbox" name="B" class="B" value="Damaskus">Damaskus
</td></tr>

<tr><td style="background-color:#EFEFFB;"><input type="checkbox" name="C" class="C" value="COLOR:">COLOR</td><td style="background-color:#EFEFFB;">
<input type="checkbox" name="C" class="C" value="Amsterdam">Blue
<input type="checkbox" name="C" class="C" value="Copenhagen">Red
<input type="checkbox" name="C" class="C" value="Green">Green
</td></tr>

<tr><td style="background-color:#EFEFFB;"><input type="checkbox" name="D" class="D" value="NUMBER:">NUMBER</td><td style="background-color:#EFEFFB;">
<input type="checkbox" name="D" class="D" value="1">1
<input type="checkbox" name="D" class="D" value="2">2
<input type="checkbox" name="D" class="D" value="3">3
<input type="checkbox" name="D" class="D" value="4">4
<input type="checkbox" name="D" class="D" value="5">5
<input type="number" name="D" min="6" max="100">Other number
</td></tr>

</table>
<br /><br />

<textarea id="countryList" rows="8" cols="61"></textarea></br>
<button class="btn" data-clipboard-action="cut" data-clipboard-target="#countryList">Cut to clipboard</button>

<br /><br />
<input type="submit" value="Output" />
<br /><br />

<b id='output1'></b><br />
<b id='output2'></b><br />
<b id='output3'></b><br />
<b id='output4'></b><br />


</body>
</html>




Make CheckBox for Dictionary in ASP.NET MVC

I display each faculty with bound specializations:

@model Dictionary<Models.Faculty, IEnumerable<Models.Specialization>>

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    <div class="form-group">
        @foreach (var faculty in Model)
        {
            <section class="faculty">
                <header>
                    @faculty.Key.Name
                </header>
                @foreach (var specialization in faculty.Value)
                {
                    <div class="checkbox">
                        <label>
                            @Html.CheckBox(What should I add HERE) <b>@specialization.Name</b> (@specialization.Description)
                        </label>
                    </div>
                }
            </section>
        }
    </div>    
}

I want to get IEnumerable of specialization.specializationId in my Controller. I cant use @Html.CheckBoxFor(), couse my model is Dictionary. How Can I do this?




When checkbox is checked in Microsoft Access 2016, insert checkbox value into a field after hitting the add entry button

This is what I have so far, and it is only adding a 1 or 0 in the Group_List field. Braillist is the checkbox value.

Private Sub Command86_Click()

If Braillist = True Then Dim str_sql As String

str_sql = "INSERT INTO NCECBVI(Group_List)value(" & Braillist & ")"


End If

End Sub




SetBox set to checked after click on textview - ExpandableListView

1) After click on textview i want to set checkbox to checked state. 2) After start a new session set these checkbox into last state (SharedPreferences). Right now i am using hashmaps for keeping state of checkboxes (i have that from some ExpandableListView tutorial).

Someone who solved this problem? Or someone who knows how solve that and can help me there or help me via skype or something?

Thanks a lot guys




Json record assigned to checkbox [duplicate]

This question already has an answer here:

I am downloading data from JSON and I would like to mark each individual displayed record with a checkbox and send marked records by e-mail.

This is my piece of code displaying json:

    $(document).ready(function(){
        $("button").click(function(){
            $.getJSON("data.json", function(result){
                $.each(result, function(i, field){
                    $("div").append("" +field + "</br>");
                                
                });
            });
        });
    });
  <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

    </head>
    
    <body>
    
    <button>Get JSON data</button>
    <div></div>
    
    </body>
    </html>

data.json :

    [
["AAA"],
["BBB"],
]

Is there anyone able to direct me how to assign JSON record to a checbox? Please, give me a hint what next.




Change checkbox list based on OptionMenu answer with tkinter

I'm having a bit of trouble with tkinter

Here's the thing : I have a dropdown (OptionMenu) that allows me to select something.

I have a tracer set on the variable from the OptionMenu that calls a function when the dropdown changes. (Function callback_project_name_changed)

When the callback is called, I check what project has been selected and display the appropriate list of checkboxes I want.

Here's the code that I have so far:

from tkinter import *
import os
import sys
from tkinter import filedialog


class Checkbar(Frame):
    def __init__(self, parent=None, picks=[], side=LEFT, anchor=W):
        Frame.__init__(self, parent)
        self.vars = []
        for pick in picks:
            var = IntVar()
            chk = Checkbutton(self, text=pick, variable=var)
            chk.pack(side=side, anchor=anchor, expand=YES)
            self.vars.append(var)

    def state(self):
        return map((lambda var: var.get()), self.vars)


class Application():
    def __init__(self):
        self.window = Tk()

    def close_window(self):
        self.window.destroy()
        sys.exit()

    def close_window_escape(self, event):
        self.window.destroy()
        sys.exit()

    def get_project_path(self):
        self.path = filedialog.askdirectory()
        print(self.path)

    def callback_project_name_changed(self, *args):
        # @todo: Make groups like when you tick `tests` it ticks all the tests
        self.project_selected = self.project.get()
        if self.project_selected == "other":
            # @todo: whitelist/blacklist for options
            self.options = Checkbar(self.window, ['author', 'norme', 'Makefile'])
            self.options.pack(side=LEFT)

        if self.project_selected == "42commandements":
            self.options = None

        if self.project_selected == "libft":
            self.options = Checkbar(self.window, ['author', 'forbidden-functions', 'makefile', 'norme', 'static', 'extra', 'required', 'bonus', 'benchmark', 'tests', 'libftest', 'maintest', 'moulitest', 'fillit-checker', 'libft-unit-test'])
            self.options.pack(side=LEFT)

        if self.project_selected == "fillit":
            self.options = Checkbar(self.window, ['author', 'forbidden-functions', 'makefile', 'norme', 'tests', 'fillit-checker'])
            self.options.pack(side=LEFT)

    def start(self):
        if self.options != None:
            print(list(self.options.state()))

    def create_window(self):
        self.window.title("42PyChecker")
        self.window.minsize(width=800, height=800)
        # @todo: Set a icon for app image
        #self.window.iconbitmap(os.path.dirname(os.path.realpath(__file__)) + "/favicon.ico")
        # @todo: Find a way to loop through gif frames to have animated logo
        logo = PhotoImage(file=os.path.dirname(os.path.realpath(__file__)) + "/logo.gif")
        Label(self.window, image=logo).pack()
        Button(self.window, text="Select Project Path", width=20, command=self.get_project_path).pack()

        self.project = StringVar(self.window)
        dropdown = OptionMenu(self.window, self.project, "other", "42commandements", "libft", 'fillit')
        dropdown.pack()

        Button(self.window, text="Start", command=self.start).pack(side=BOTTOM)

        Button(self.window, text="Exit", command=self.close_window).pack(side=BOTTOM)
        self.window.bind('<Escape>', self.close_window_escape)

        self.project.trace("w", self.callback_project_name_changed)
        self.window.mainloop()
app = Application()
app.create_window()

If you run it and change the dropdown multiple times (to the same one or different option), it'll only add more checkboxes and won't delete any. I guess that's supposed to happen as I am not deleted anything, just adding CheckBars every time the dropdown menu is changed.

Now let's change some code and try to add .destroy() or .pack_forget() :

    def callback_project_name_changed(self, *args):
        # @todo: Make groups like when you tick `tests` it ticks all the tests
        self.project_selected = self.project.get()
        if self.project_selected == "other":
            self.options.destroy()
            # @todo: whitelist/blacklist for options
            self.options = Checkbar(self.window, ['author', 'norme', 'Makefile'])
            self.options.pack(side=LEFT)

        if self.project_selected == "42commandements":
            self.options = None

        if self.project_selected == "libft":
            self.options.destroy()
            self.options = Checkbar(self.window, ['author', 'forbidden-functions', 'makefile', 'norme', 'static', 'extra', 'required', 'bonus', 'benchmark', 'tests', 'libftest', 'maintest', 'moulitest', 'fillit-checker', 'libft-unit-test'])
            self.options.pack(side=LEFT)

        if self.project_selected == "fillit":
            self.options.destroy()
            self.options = Checkbar(self.window, ['author', 'forbidden-functions', 'makefile', 'norme', 'tests', 'fillit-checker'])
            self.options.pack(side=LEFT)

Now, when selected, the output gives me an error because self.options hasn't been initialized. So i've found a workaround, just a is_initialized set to 0 or 1 did the trick.

Yet, the checkboxes weren't being deleted, just kept being added.

TL;DR: It doesn't deletes checkboxes when changed. What I want to achieve is having different checkboxes list based on what has been selected through the OptionMenu

Is there any simpler way ?




how do I toast the number of checked boxes in my RecyclerView?

My code below works perfect when the activity loads with all checkboxes checked, or all checkboxes unchecked, and they are checked or unchecked from that point on, but the problem is that in reality the activity might load with SOME checkboxes checked.

I suppose the key is count = 0; If I could set count to the number of checked boxes when the form loads...

This is what I have in the setOnClickListener(new View.OnClickListener() { of my adapter, works for when all checkboxes start from a checked or unchecked position:

                //we want to keep track of checked boxes
                int count;
                count = 0;
                int size = MatchingContactsAsArrayList.size();
                for (int i = 0; i < size; i++) {
                    if (theContactsList.get(i).isSelected) {
                        count++;
                    }

                }

                  if (count == 0) {

                        Toast.makeText(context_type, "count is 0!", Toast.LENGTH_SHORT).show();

                } else {

                        Toast.makeText(context_type, "The count is " + count, Toast.LENGTH_SHORT).show();

                }




Excel Check-Box see if checked

I have a chekcbox that has transformed into a AutoShape type as in if you run the follwing code you get Type 1: Print ActiveSheet.Shapes("Check Box 5").Type 1

Is there a way to see if it is checked?

I have tried the following codes but they do not work:

ActiveSheet.Shapes("Check Box 5").OLEFormat.Object.Value = 1

ActiveSheet.Shapes("Check Box " & i).ControlFormat.Value = False




lundi 19 février 2018

PrestaShop 1.7 attribute as check box?

Good day. There was such problem: it is necessary to implement for the goods the possibility of adding several goods to the basket, with the chosen sizes. I am digging through the AttributeGroup.php files.

private $groupTypeAvailable = array(
    'select',
    'checkbox',
    'color',
);

Next AdminAttributesController.php

$group_type = array(
        array(
            'id' => 'select',
            'name' => $this->trans('Drop-down list', array(), 'Admin.Global')
        ),
        array(
            'id' => 'checkbox',
            'name' => $this->trans('Radio buttons', array(), 'Admin.Global')
        ),
        array(
            'id' => 'color',
            'name' => $this->trans('Color or texture', array(), 'Admin.Catalog.Feature')
        ),
    );

and in product-variants.tpl

{elseif $group.group_type == 'checkbox'}
    <ul id="group_{$id_attribute_group}">
      {foreach from=$group.attributes key=id_attribute item=group_attribute}
        <li class="input-container float-xs-left">
          <label>
            <input class="" type="checkbox" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}">
            <span class="radio-label">{$group_attribute.name}</span>
          </label>
        </li>
      {/foreach}
    </ul>
  {/if}

For this I can choose several checkboxes, but the last selected is added to the basket.

enter image description here




Adding Line Items and Check boxes by button

Word Doc Template

Item 1: I would like to be able to click this plus sign that will then add a checkbox that's similar to what Item 2 is pointing at.

Item 3: I would like to click the plus sign and it will create an original copy of the group within the pointers of Venue/Site.




Checkbox group, submit button only if at least one checkbox is checked Angular

Hy, So I have a checkbox group with 3 items. I created it with Angular 5.0.5 and Clarity vm. I want my function to check if at least one of the checkboxes is checked and THEN go at the next page, which is a wizard. Until now the wizard opens without checking if at least one checkbox is selected.

My html looks like this:

`<table class="table">
<tbody>
<tr *ngFor="let item of items">
<td>
<input  type="checkbox" name="allowNext" [(ngModel)]="item.chosen">
</td>
<td>

</td>
</tr>
</tbody>
</table>
<br>
</form>
<button [disabled] class="btn btn-primary" (click)="go()"> Next </button>`

my Typescript for it looks like this:

` items= [
    {name: 'checkbox1', chosen: false},
    {name: 'checkbox2', chosen: false},
    {name: 'checkbox3', chosen: false}
  ];
 go() {
 if(this.items.chosen === true) {
 this.wizard.open();
 ngOnInit () {}
 constructor( public router: Router) {}`

could you guys please help me define the function correclty? Thanks in advanced!




How to verify if if checkbox is checked or unchecked in C#

How to verify if checkbox is checked or unchecked in C# ? Because method "element.Selected" does not work in this case.

Here it is html code if checkbox is checked:

<td class="dxgvCommandColumn_MetropolisBlue dxgv" onclick="aspxGVScheduleCommand('messageGrid',['Select',1],1)" align="center">
<span id="messageGrid_DXSelBtn1_D" class="dxICheckBox_MetropolisBlue dxichSys dxWeb_edtCheckBoxChecked_MetropolisBlue">
<input id="messageGrid_DXSelBtn1" value="U" readonly="readonly" style="border-width:0;width:0;height:0;padding:0;margin:0;position:relative;background-color:transparent;display:block;" type="text"/>
</span>
</td>

Here it is html code if checkbox is unchecked:

<td class="dxgvCommandColumn_MetropolisBlue dxgv" onclick="aspxGVScheduleCommand('messageGrid',['Select',1],1)" align="center">
<span id="messageGrid_DXSelBtn1_D" class="dxWeb_edtCheckBoxUnchecked_MetropolisBlue dxICheckBox_MetropolisBlue dxichSys">
<input id="messageGrid_DXSelBtn1" value="U" readonly="readonly" style="border-width:0;width:0;height:0;padding:0;margin:0;position:relative;background-color:transparent;display:block;" type="text"/>
</span>
</td>

Image: checkboxes




dimanche 18 février 2018

How to send multiple checked values to db and append value to each object?

I have a form with checkboxes. One or many can be selected to be send to db.

The form is used to register damages on assets, so there is a relation to "current_id" which is the unique asset. 1:n relation. Since I need to send the current_id as a foreign key I push it on the form array like so formData.push({name: 'id', value: current_id});

This works fine when only one checkbox is selected. But when I have multiple options checked I cannot send to the server. I struggle to solve this. I have looked into using map, but I was not sure how to implement it to send a correct array to the database.

Help would be much appreciated

$('form').submit(function(e){
  e.preventDefault();
  let formData = $(this).serializeArray();
  
  formData.push({name: 'id', value: current_id});
});

$.post({
  type: 'POST',
  url: '/api',
  data: formData
})

// what i tried..
// for multple checked boxes
// this did not work

//formData.forEach(function (data){
//  data.push({name: 'id', value: current_id});
//  $.post({
//    type: 'POST',
//    url: '/api',
//    data: formData
//  })
//})
<form id="damages">
  <input type="checkbox" name="damage" value="loose" checked="checked" />
  <input type="checkbox" name="damage" value="broken" />
</form>



check uncheck all after some checkboxes are clicked

   <input id='checkall' type='checkbox'> 

   <input class='checka' type='checkbox'>
    <input class='checka' type='checkbox'>
    <input class='checka' type='checkbox'>
    <input class='checka' type='checkbox'>

js

$('#checkall').change(function(){
    if ($(this).is(':checked')){
        $('.checka').attr('checked', true);
    }
    else{
        $('.checka').attr('checked', false);
    }
});

After loading the page this works fine.

But if some of the checka is checked/unchecked before checkall click - it works only on non-clicked checka.




R Shiny, how to make datatable react to checkboxes in datatable

I would like my datatable to display content which depends on the status of checkboxes contained in the table. I have found help with both, including checkboxes in a DT as well as changing data table content, but when I try and combine these solutions I don't get what I want. When checking a box, the table is redrawn twice, the first time the way I want but a moment later it switches back.

This is the code which should almost do... Is there someone out there to help before I get crazy?

library(shiny)
library(DT)
shinyApp(
  ui = fluidPage(
    DT::dataTableOutput('x1'),
    verbatimTextOutput('x2')
  ),

  server = function(input, output, session) {
    # create a character vector of shiny inputs
    shinyInput = function(FUN, len, id, ...) {
      inputs = character(len)
      for (i in seq_len(len)) {
        inputs[i] = as.character(FUN(paste0(id, i), label = NULL, ...))
      }
      inputs
    }

    # obtain the values of inputs
    shinyValue = function(id, len) {
      unlist(lapply(seq_len(len), function(i) {
        value = input[[paste0(id, i)]]
        if (is.null(value)) TRUE else value
      }))
    }

    n = 6
    df = data.frame(
      cb = shinyInput(checkboxInput, n, 'cb_', value = TRUE, width='1px'),
      month = month.abb[1:n],
      YN = rep(TRUE, n),
      ID = seq_len(n),
      stringsAsFactors = FALSE)

    loopData = reactive({
      df$YN <<- shinyValue('cb_', n)
      df
    })

    output$x1 = DT::renderDataTable(
      isolate(loopData()),
      escape = FALSE, selection = 'none',
      options = list(
        dom = 't', paging = FALSE, ordering = FALSE,
        preDrawCallback = JS('function() {    Shiny.unbindAll(this.api().table().node()); }'),
        drawCallback = JS('function() { Shiny.bindAll(this.api().table().node()); } ')#,
      ))

    proxy = dataTableProxy('x1')

    observe({
      replaceData(proxy, loopData())
    })

    output$x2 = renderPrint({
      data.frame(Like = shinyValue('cb_', n))
    })
  }
)




How to post data value to a web service from a checkbox Angular 4

I'm building a registration form which is like: User enters his details - chooses his type (teacher or student)

And then chooses which class and grade he belongs to.

So i'm getting grades and classes data from a web service and i put it in a NgFor using checkbox.

And using POST method to send HTTP with user details to another web service.

Now i want to know the way to post data value from a checkbox to the web service, like if he checked class 2A it posts to the API (2A)

How do i do that? if somebody has a resource or knows the way.

My component TS:

name: any[];
email: any[];
password: any[];
type_id: number[] = [];
school_id: any[];
grade_id: any[] = [];
class_id: any[] = [];
subject_id: any[] = [];
grades:string;
classes:string;
subjects:string;
id: number[] = [];
imageFile: any;
type_name: any[];
public selectedSchoolId: number;
public schoolDetail: SchoolsModel;
public divisionList: SchoolsModel[];
private url = 'http://crm.easyschools.org/api/en/users/register';

getFile(event){
this.imageFile =  event.target.files[0];
}
onSubmit(form: NgForm) {
var data = form.value;
let formData: FormData = new FormData();
// debugger;
formData.append('image', this.imageFile, this.imageFile.name);
formData.append('name', data.name);
formData.append('email', data.email);
formData.append('password', data.password);
formData.append('type_name', data.type_name);
formData.append('type_id', this.type_id);
formData.append('school_id', this.selectedSchoolId;
formData.append('class_id[0]', 7);
formData.append('grade_id[0]', 17);
formData.append('subject_id', 9);
this._http.post(this.url, formData)
  .subscribe(response => {
    // debugger;
    console.log(response);
  }, (err: HttpErrorResponse) => {
    console.log(err);
  });

}

ngOnInit(): void {
this.route.params.subscribe((params) => {
  this.selectedSchoolId = +params.id;
  this.getSelectedSchoolDetail();
});
}

My component HTML:

<form #registerForm="ngForm" enctype="multipart/form-data"><!--== 
start form ==-->
<div  class="col-md-12 " id="append-types-here" style="text-align: 
center;">
<div class="row col-md-12">
<input name="name" ngModel #name="ngModel" style="text-align: 
left;" type="text" class="rounded-inputs26 col-md-6 add-account-
inputs1" placeholder="Fullname ">
</div>
<input name="email" ngModel #email="ngModel" style="text-align: left;" 
type="email" class="rounded-inputs26 col-md-6 add-account-inputs1" 
placeholder="Email" >
<input name="password" ngModel #password="ngModel" style="text-align: 
left;" type="password" class="rounded-inputs26 col-md-6 add-account-
inputs1" id="password1" placeholder="Password" >
<input name="password" style="text-align: left;" type="password" 
class="rounded-inputs26 col-md-6 add-account-inputs1" 
id="confirm_password1" placeholder="Confirm password" >
<span id='message1'></span>
<select id="select-type" [(ngModel)]="type_id" name="type_id"  
class="rounded-inputs26 col-md-6 add-account-inputs1">
<option selected="selected">Account Type...</option>
<option id="type1" [ngValue]="3"><span name="type_name" 
type="text">Teacher</span></option>
<option id="type2" [ngValue]="4">Parent</option>
<option id="type3" [ngValue]="5">Student</option>
</select>
</div>
<div  id="third-type" class="row col-md-12">
<ng-container *ngIf="divisionList">
<div class="col-md-3" style="margin: auto;overflow: auto;">
<div style="list-style: none;background-color:#054360;padding: 
10px;color:white;">
<input class="choose-choose5" type="checkbox"> Grades:</div>
<div  style="background-color:white;border: solid 1px #004360;float: 
left;width: 100%;">
<h6 *ngFor="let division of divisionList" class="pull-left col-md-12" 
style="border-bottom:1px solid #999999;padding-top: 5px;">
<input (change)="onChangeGrade($event.target.value)" style="float: 
left;margin-left:25px;" class="choose-choose11" type="checkbox" id="">
<label  style="padding-right: 90px;white-space: nowrap;">
</label>
</h6>

</div></div>
<div class="col-md-3" style="margin: auto;overflow: auto;">
<div style="list-style: none;background-color:#054360;padding: 
10px;color:white;">
<input class="choose-choose6" type="checkbox"> Classes:</div>
<div style="background-color:white;border: solid 1px #004360;float: 
left;width: 100%;">
<h6   *ngFor="let division1 of divisionList" class="pull-left col-md-
12" style="border-bottom:1px solid #999999;padding-top: 5px;">
<input (change)="onChangeClass($event.target.value)" style="float: 
left;margin-left:25px;" class="choose-choose12" type="checkbox" >
<label  style="padding-right: 90px;white-space: nowrap;">
</label></h6>

</div></div>

<div class="col-md-3 hide" id="subjects-select" style="margin: 
auto;overflow: auto;">
<div style="list-style: none;background-color:#054360;padding: 
10px; color:white;"> Subjects:</div>
<div style="background-color:white;border: solid 1px #004360;float: 
left;width: 100%;">
<h6 *ngFor="let division2 of divisionList" class="pull-left col-
md-12" style="border-bottom:1px solid #999999;padding-top: 5px;">
<input style="float: left;margin-left:25px;" type="radio" 
name="choose2" id="third-select7">
<label for="third-select7" style="padding-right: 90px;white-
space: nowrap;">
</label></h6>

</div>
</div>
</ng-container>
</div>

<input type="file" name="image" (change)="getFile($event)" 
multiple="multiple" accept="image/*" ngModel #image="ngModel">
<div class="row col-md-12 col-sm-12 col-xs-12 " style="margin-top: 
70px; text-align: center;">
<div class="col-md-4 ">
</div>
<div class="col-md-4">
<button (click)="onSubmit(registerForm)" class="school-footer-
button17" routerLink="/dashboard/:id" style="margin: 
auto;">Submit</button>
</div>
<div class="col-md-4 ">
</div>
</div>
</form><!--== end form ==-->

If you need any more data, code or clarification kindly let me know.




select multiple checked box to retrieve data from the database and display the selected data

i want to select multiple check boxes to retrieve data from database and display the checked boxes. but now i am having problem displaying the checked boxes. i have no error but i cannot display my checked data. this is my coding

 <?php
 $sql = "select * from contact_master";
 $query  = mysqli_query($conn, $sql) ;
 while ($row = mysqli_fetch_array($query)){
?>
<tr class="odd gradeX" >
<td><input type="checkbox"  name="chk[]" class="chk-box"/></td>

<td><?php echo $row['Contact_Name'];       ?> <input type="checkbox"  id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>   

<td ><?php echo $row['Contact_Phone'];     ?><input type="checkbox"  id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()" /></td>                                                                   <td><?php echo $row['Contact_Email'];      ?><input type="checkbox" id="myCheck"  name="chk[]" class="chk-box" onclick="myFunction()"/></td>                  
<td ><?php echo $row['Contact_Facebook'];  ?><input type="checkbox" id="myCheck"  name="chk[]" class="chk-box" onclick="myFunction()"/></td>                    <td ><?php echo $row['Contact_Wechat'];     ?><input type="checkbox" id="myCheck"  name="chk[]" class="chk-box" onclick="myFunction()"/></td>                  
<td ><?php echo $row['Contact_Whatsapp'];  ?><input type="checkbox" id="myCheck"  name="chk[]" class="chk-box" onclick="myFunction()"/></td>              
<td ><?php echo $row['Contact_Linkin'];    ?><input type="checkbox" id="myCheck"  name="chk[]" class="chk-box" onclick="myFunction()"/></td>                   
<td ><?php echo $row['Contact_Twitter'];   ?><input type="checkbox" id="myCheck" name="chk[]" class="chk-box" onclick="myFunction()"/></td>                             
             <input type="submit" name="submit" value="Submit"/>

//this is how i connect data from the database
<?php

$sql = "SELECT * FROM contact_master";
$result = mysqli_query( $conn, $sql );


if( $result ){
// success! check results
while( $row = mysqli_fetch_assoc( $result )){

$i = 0
{
    $Contact_Name = $row['Contact_Name'];
if(isset($_POST[$Contact_Name])!=NULL)
{
$i = 0; 
$i++;

mysqli_query("select * from contact_master Where Contact_Name = $Contact_Name")or die(mysql_error());
}}}}
$i = 0; 
echo "Selected Contact".$i['Contact_Name']
?>
</html>
</tr>




itext 7 (.ET) how to display info in a checkbox field

We are making a program with iText7 under .NET.

We need to incorporate a checkbox field in a PDF file.

Here are specific lines of our program :

var writer = new PdfWriter(cPdfNameOut);
var pdf = new PdfDocument(writer);
var document = new Document(pdf);
...
PdfAcroForm form = PdfAcroForm.GetAcroForm(document.GetPdfDocument(), true);
...
var table = new Table(new float[] {2.5F, 0.2F, 1.8F, 1.8F, 1.5F });
PdfAcroForm form = PdfAcroForm.GetAcroForm(document.GetPdfDocument(), true);
...
Cell cell = new Cell();
...
table.AddCell(cell);
...
string cFieldName = ...;
iText.Kernel.Geom.Rectangle rectangle = ...;
...
PdfButtonFormField nameField = PdfChoiceFormField.CreateCheckBox(document.GetPdfDocument(), rectangle, cFieldName, "Yes", PdfFormField.TYPE_CHECK);
form.AddField(nameField);

Line PdfButtonFormField nameField ... :

  • when we indicate "Yes" as default value, the resulting PDF file reacts as we expect, to know that the check icon is displayed alternatively when we click inside the field.
  • when we indicate "Off" as default value, the check icon is NOT displayed alternatively when we click inside the field, uptil we click outside the checkbox field (then, the checkbox icon can be seen)

How is it possible to make the checkbox field reacts as we expect when the initial value is "Off" ?

Thank you in advance for your answer.




samedi 17 février 2018

Updating dataset filter using multiple checkbox selection in d3

Page in question: https://3milychu.github.io/met-erials

Goal:

  • I have multiple checkboxes, they need to update a dataset filter upon selection
  • Each time a checkbox is checked, an update function should run to see which checkboxes are checked, and filter the data accordingly.

The html:

<!-- Selector -->
<div id="selector">
    <form>
    <label onclick="showTile()">All<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="All" checked></label>
    <label onclick="showTile()">Wood<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasWood"></label>
    <label onclick="showTile()">Silk<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasSilk"></label>
    <label onclick="showTile()">Ink<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasInk"></label>
    <label onclick="showTile()">Silver<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasSilver"></label>
    <label onclick="showTile()">Glass<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasGlass"></label>
    <label onclick="showTile()">Steel<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasSteel"></label>
    <label onclick="showTile()">Gold<input class="radio-custom" type="checkbox" name="dataset" id="dataset" value="hasGold"></label>
    </form>
</div>

The js:

d3.select("input[value=\"All\"]").property("checked", true);
            d3.selectAll("input").on("change", update);
            update(data);

function update(dataset) {

// change dataset to selected dataset   

d3.selectAll(".radio-custom").each(function(d){
  cb = d3.select(this);
  if(cb.property("checked")){
    newData = dataset.filter(function(d,i){return d.this== 1;});
    }
  });
};




how to add items for listview with checkbox

I am new in android studio, I want view data from database using listview with checkbox. I found simple code from this link Listview with checkbox

I tried and i can't put data from database to code :

// Create and populate planets.  
planets = (Planet[]) getLastNonConfigurationInstance() ;  
if ( planets == null ) {  
  planets = new Planet[] {   
      new Planet("Mercury"), new Planet("Venus"), new Planet("Earth"),   
      new Planet("Mars"), new Planet("Jupiter"), new Planet("Saturn"),   
      new Planet("Uranus"), new Planet("Neptune"), new Planet("Ceres"),  
      new Planet("Pluto"), new Planet("Haumea"), new Planet("Makemake"),  
      new Planet("Eris")  
  };    
}  

I have tried using simple iteration like

for(int i=0;i<list_from_db.size();i++)
{ 
   new Planet(list_from_db.get(i));
}

May I get the help how to do this.




vendredi 16 février 2018

How do I use my accordion's checkboxes within my order wizard?

I've posted my controller, model, form view & partial view for the checkbox step code I'm struggling with below.

Up until now, I had been using radio buttons for selecting 1 specific value out of multiple options during each step of the wizard. It's worked perfectly and saves to the database correctly how I'd like.

However, for the last step in the wizard, I need to choose multiple values out of the options and have resorted to check_boxes for this.

My problem is, I'm not sure how to correctly save the multiple check_box values to my current model, how to express this in my views correctly and/or if creating a new model for this specific attribute, how to hook it up with how the code is currently set up for the wizard.

I'm currently using the accordion headers as categories to open up the check_box options that will end up saving all together.

IE; 1st guide__choice opens up the panel showing multiple check_box values, 2nd guide__choice opens up a different panel showing it's own category of check_box values, but the Order model needs to know about both the 1st and 2nd guide__choice check_box values.

To me, it sounds like I need a new model or 2 where I can save each guide__choice as a category with the check_boxes values belonging to the category, but I'm not sure how I would hook this all up to the order wizard to go along with the other model. My best guess is having a has_many :through relationship set up between the Order -> newModel :through newModel2

Writing this all out is making me start to think I'll have to/should have a new model for all the attributes i'm using for the Order. But wouldn't that also start calling the database way more often than is necessary?

All and any help is much appreciated, thank you!~

#### MY CONTROLLER ####
class OrdersController < ApplicationController
  def new
    session[:order_params] ||= {}
    @order = Order.new(session[:order_params])
    @order.current_step = session[:order_step]
  end

  def create
    session[:order_params].deep_merge!(params[:order]) if params[:order]
    @order = Order.new(session[:order_params])
    @order.current_step = session[:order_step]
    if @order.valid?
      if params[:back_button]
        @order.previous_step
      elsif @order.last_step?
        @order.save
      else
        @order.next_step
      end
      session[:order_step] = @order.current_step
    end
    if @order.new_record?
      render "new"
    else
      session[:order_step] = session[:order_params] = nil
      flash[:notice] = "Order Saved!"
      redirect_to @order
    end
  end
end

#### MY MODEL ####
class Order < ApplicationRecord
  attr_writer :current_step
  validates_presence_of :attr_one, :if => Proc.new { |o| o.current_step == "step-1" }
  validates_presence_of :attr_two, :if => Proc.new { |o| o.current_step == "step-2" }
  validates_presence_of :attr_three, :if => Proc.new { |o| o.current_step == "step-3" }
  validates_presence_of :attr_four, :if => Proc.new { |o| o.current_step == "step-4" }

  def current_step
    @current_step || steps.first
  end

  def steps
    %w[step-1 step-2 step-3 step-4]
  end

  def next_step
    self.current_step = steps[steps.index(current_step)+1]
  end

  def previous_step
    self.current_step = steps[steps.index(current_step)-1]
  end

  def first_step?
    current_step == steps.first
  end

  def last_step?
    current_step == steps.last
  end
end

#### MY FORM VIEW ####
##### ...ommitting if modelObject.errors.any? block #####
<section class="guide"%>
  <%= render "orders/partials#{order.current_step}-step", :f => f %>
  <div class="actions">
    <div class="guide__next-step">
      <%= button_tag(type: 'submit') do %>
        <h1>Next step</h1>
      <% end %>
    </div>
    <%= f.submit "Back", :name => "back_button" unless order.first_step? %>
  </div>
</section>

#### THE STEP PARTIAL CHECKBOX VIEW I NEED HELP WITH ####
<div class="accordion guide__choices">
  <h3 class="guide__choice">Header 1 drops down checkbox 1 panel</h3>
  <div class="accordion__panel">
    <%= f.check_box :attr_four, {}, "choiceOne" %>
    <%= f.label :attr_four, "Choice One", :value => "choiceOne" %>
  </div>

  <h3 class="guide__choice">Header 2 drops down checkbox 2 panel</h3>
  <div class="accordion__panel">
    <%= f.check_box :attr_four, {}, "choiceTwo" %>
    <%= f.label :attr_four, "Choice Two", :value => "choiceTwo" %>
  </div>

  <h3 class="guide__choice">Header 3 drops down checkbox 3 panel</h3>
  <div class="accordion__panel">
    <%= f.check_box :attr_four, {}, "choiceThree" %>
    <%= f.label :attr_four, ""Choice Three", :value => "choiceThree" %>
  </div>
</div>




Changing div colour with label and checkboxes

I am trying to change the colour of the item1 div by checking the labels and it's inputs. For some reason, it only works when you check the first two checkboxes but not the last one. Can you please explain why is this happenning?

  <style type="text/css">
     .item1 {
     width: 100px;
     height: 100px;
     }
     #item-1:checked + label .item1 {
     background: red;
     } 
     #item-2:checked + label .item1 {
     background: blue;
     }
     #item-3:checked + label .item1 {
     background: purple;
     }
  </style>


  <label for="item-1"> label 1
  <input type="checkbox" name="" id="item-1">
  <label for="item-2"> label 2
  <input type="checkbox" name="" id="item-2">
  <label for="item-3"> label 3
  <input type="checkbox" name="" id="item-3">
  <div class="item1">
  </div>




Creating a loop to count number of checkboxes Powerpoint

I have slideshow with an action button that allows the viewer to advance the slide ONLY if all the checkboxes on the page are filled in, Some slides have between 1 and 20 checkboxes. I want to create a for loop that will count the number of control check boxes on each slide so that my action button knows how many checkboxes it must confirm have been clicked.

I ran across this bit of code

Private Sub CommandButton1_Click()
Dim ctl As Control
Dim j As Long
For Each ctl In Me.Controls
If TypeOf ctl Is MSForms.CheckBox Then
 j = j + 1
End If
Next
Unload Me
End Sub

How do I get this to work in Powerpoint??? I'm struggling to find the correct checkbox syntax




Change checkbox background colour when checked in shiny:checkboxGroupInput()

I've built a shiny app with checkboxGroupInput's that as a default show blue background when checked, e.g.

checkboxGroupInput("water", "Water Level",
          choiceValues = c('Low', 'Medium','High'),
          selected = 'High')

enter image description here

Now, I want to change check box background colour to dark grey when checked (HEX #666666) using CSS within the app.

I tried the following CSS options, with no change to app's look:

tags$style(HTML('

    .checkbox input[type="checkbox"]:checked {
        position: absolute;
        margin-left: -20px;
        box-shadow: #666666;
        background-color: #666666;

section.sidebar .shiny-input-container:checked {
    padding: 12px 15px 0px 15px;
    white-space: normal;
    color: #423F3D;
    box-shadow: #666666;
    background-color: #666666;'
}

Any ideas how to achieve it?




Update ng-model value of checkbox value on the basis of other checkbox ng-model

I'm trying to update a checkbox on the basis of other checkbox.

Here is my first checkbox that is enabled and user can change its value;

<label>
  <input type="checkbox" id="chkAddVerification" name="chkAddVerification" 
  ng-model="chkAddVerification" ng-checked="chkAddVerification">
  Add Verification
</label>

And this is second checkbox that is disabled and updated according to first checkbox value;

<label>
   <input type="checkbox" id="chkSendCodeByEmail" name="chkSendCodeByEmail" 
   ng-model="chkSendCodeByEmail" ng-disabled="true" ng-checked="chkAddVerification">
   By Email
</label>

This is how I'm trying to bind first checkbox ng-model value to second checkbox ng-checked : ng-checked="chkAddVerification"

Apparently it is working fine (checking/ unchecking of second according to first one) but it does not update ng-model value of second checkbox.

If I check first checkbox chkAddVerification, second one also checks accordingly but ng-model chkSendCodeByEmail has false value in it.

What I'm missing here??




jeudi 15 février 2018

Filter GridView through TextBox without loosing the checkBox inside the grid in c#

i have this problem about DataGridView with checkbox inside. i populate the gridview by using a data table and pass it to the binding source. enter image description here

the problem starts here when i search on the textbox, all the checkbox become unchecked. enter image description here

here is my code in filtering the grid using textbox

BindingSource bs;
bs.Filter = string.Format("NAME LIKE '%{0}%'", txtSearch.Text);