lundi 29 février 2016

Polymer 0.5: paper-checkbox issue

I have a paper-checkbox inside a template repeat as below

<core-selector id="moduleSelector" valueattr="label" notap?="{{true}}">
  <template repeat="{{modules in moduleslist}}">
    <core-label horizontal layout>
        <paper-checkbox  id="modulecheckbox" checked="{{modules.checked}}" label="{{modules.pname}}" on-change={{checkboxHandler}} noink></paper-checkbox>
    </core-label>
    <br>
  </template>
 </core-selector>

Initially I fill this with some modules. Its an object with properties checked and pname.

Now after the list is populated, i get some entries dynamically and I add them like moduleslist.push(obj) where var obj={pname:"abc",checked:true}. When I do this I get an error as below

polymer.js:4887 Exception caught during observer callback: TypeError: Cannot read property 'checkbox' of undefined. This happens at paper-checkbox.html line 92- var cl = this.$.checkbox.classList; in function checkedChanged

The result is that the checkbox is unchecked but added to the list.

This might be an issue with polymer 0.5 as its an unstable version, I know the new one might have this fixed. But I am hoping to find a temporary solution/workaround to my problem as I can't do an upgrade at this stage of my work.

Thanks !




Android studio move check box to right of table cell

I have created a table view inside of a list view in Android studio (see following code) and for various reasons I have used a text view and a checkbox as separate elements rather than just having the checkbox and attaching the text. The problem is the text is on the left of the screen/table but the checkbox is essentially centred where as I want it to be at the far right hand side.

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/title"
    android:layout_above="@+id/Button1"
    android:id="@+id/scrollView"
    android:background="@drawable/list">

<TableLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="@string/Maths"
        android:id="@+id/Maths"
        android:layout_column="1"
        android:textColor="#ffffff" />
        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/MathsCheck"
            android:layout_column="2"
            android:buttonTint="#00ffff"
            android:onClick="MathsClicked"/>
    </TableRow>

    <TableRow
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="@string/History"
            android:id="@+id/History"
            android:layout_column="1"
            android:textColor="#ffffff"/>
        <CheckBox
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/HistoryCheck"
            android:layout_column="2"
            android:onClick="HistoryClicked"
            android:buttonTint="#00ffff" />
    </TableRow>
</TableLayout>
</ScrollView>

There are in reality a lot more of these text view and checkboxes but you get the idea. I have tried using padding and margins but that doesn't really work as it will work ok on some devices displays but I have to hard code it which isn't ideal. I've also tried the gravity feature which for some reason doesn't seem to do anything.

Any help appreciated




How to ensure previous checkbox is checked to enable current checkbox

I am trying to perform validations on coffeescript to enable the checkbox only if the previous checkbox is checked for a list of tasks. My current codes are below.

    - @job.tasks.each do |task|
     - if (not @job.started?) || @job.final_price.zero?
      .checkbox
     - elsif task.completed?
      .checkbox.enable
        i.checkmark.icon
     -else
      = link_to '', complete_gogetters_task_path(task), method: 'put', class: 'checkbox enable', id:"ck_submit1", onclick: 'Form_one()', num: task.id

How to I find the previous task? I want to do something like:

    - @job.tasks.each do |task|
     - if (not @job.started?) || @job.final_price.zero? || task.prev.not_completed?
      .checkbox
     - elsif task.completed?
      .checkbox.enable
        i.checkmark.icon
     -else
      = link_to '', complete_gogetters_task_path(task), method: 'put', class: 'checkbox enable', id:"ck_submit1", onclick: 'Form_one()', num: task.id

Appreciate any help. Thanks!




asp.net check if checkbox in gridview is checked

Gridview with a select-button, a boundfield and a checkbox. Binding the data to the gridview works fine. (the data in the DB has an NVARCHAR column for the bounfield and a BIT column for the checkbox.

When selecting a row via the 'Select' button, an event in code-behind is fired, and data from the 2 cells from the gridview are copied to 2 controls on the page: a textbox and checkbox.

The first works ok and I have no clue as to how to check if the checkbox in the gridview is checked or not. I need to know that so that I can populate other checkbox control accordingly.

(before I paste my code: I just spent some 12 hours searching for a solution here in SO and elsewhere. None of the numerous entries helped. So please bear with me...)

<asp:GridView ID="grv_Test1" runat="server" CssClass="myGrid"
    AutoGenerateColumns="False" DataKeyNames="Test1_First_Name"
    OnRowCommand="grv_Test1_RowCommand">
    <Columns>
        <asp:CommandField SelectText="sel'" ShowSelectButton="True" ControlStyle-CssClass="btn btn-primary myBtn-xs">
        </asp:CommandField>
        <asp:BoundField DataField="Test1_First_Name" HeaderText="Name"><HeaderStyle Width="85px" />
        </asp:BoundField>
        <asp:CheckBoxField DataField="Test1_Active" HeaderText="Active">
        </asp:CheckBoxField>
    </Columns>
    <HeaderStyle CssClass="myGridHeader" />
</asp:GridView>  

Code behind:

int my_Data_From_Grid = Convert.ToInt32(e.CommandArgument);
txb_Test1_Name.Text = grv_Test1.Rows[my_Data_From_Grid].Cells[1].Text;            // this works

cbx_Test1_Active.Text = grv_Test1.Rows[my_Data_From_Grid].Cells[2].Text;          // NOT working

if (Convert.ToString(grv_Test1.Rows[my_Data_From_Grid].Cells[2].Text) == "1")     // NOT working either
   { cbx_Test1_Active.Checked = true; }
else
   { cbx_Test1_Active.Checked = false; }

if (Convert.ToString(grv_Test1.Rows[my_Data_From_Grid].Cells[2].Text) == "True")  // NOT working either
   { cbx_Test1_Active.Checked = true; }
else
   { cbx_Test1_Active.Checked = false; }

Here is what I got when selecting Michael's row:
enter image description here
In the gridview Michael is "Active", and I need the checkbox at the top to be 'checked'.
How can it be done...? Thnaks a lot.




Can't get value from checkbox Thymeleaf

<input id="isChecked" name="isChecked"
                    type="checkbox"></input><input name="_isChecked"
                    type="hidden" value="on"></input> <label for="isChecked">Checked</label>

I have this checkbox on the top of my *.html. I want to use the value of "isChecked" input in a "form" like seting 1/0 (true/false) to a hidden input:

<form id="someForm" class="form xml-display form-inline"
                th:action="@{/doSomething}" method="post">
.....
    <input type="hidden" name="isChecked"
                       th:value="GET VALUE FROM THE GLOBAL CHECKBOX" />
.....
</form>

So can I do this without any JS? Should I add an object in my java controller to the Model so I can set the value from the "isChecked" checkbox to it and then use the object in th:value="${objectFromJavaController}" for the hidden input ? I tried setting a th:object="${objectFromJavaController}" for the checkbox and then passing it to the hidden input but it didn't work (th:value = ${"objectFromJavaController"}) ?

So can someone help me ? Thanks in advance!




Check if all checkbox are checked not working

i try to check if all checkbox are checked and change the class of an button. But my code are not working and i don't know why.

  <input type="checkbox" id="check1" onchange="checkIfChecked();" class="checkThis" value="check 1"> Check 1<br />
<input type="checkbox" id="check2" onchange="checkIfChecked();" class="checkThis" value="check 2"> Check 2<br />
<input type="checkbox" id="check3" onchange="checkIfChecked();" class="checkThis" value="check 3"> Check 3<br />
<input type="checkbox" id="check4" onchange="checkIfChecked();" class="checkThis" value="check 4"> Check 4<br />
<input type="checkbox" id="check5" onchange="checkIfChecked();" class="checkThis" value="check 5"> Check 5<br /><br />
<a href="#" style="width:190px;display:block;" id="absenden" class="button-theme-disable">
    <span class="span_outer">
        <span class="span_right">
            <span class="span_left">
                <span style="width: 182px;" class="span_inner">Speichern & Schließen</span>
            </span>
        </span>
    </span>
</a>
    function checkIfChecked() {

    if ($('.checkThis input[type="checkbox"]').not(':checked').length == 0) {
        $('#absenden').removeClass('button-theme-disable');
        $('#absenden').addClass('button-theme');
    } else {
        $('#absenden').removeClass('button-theme');
        $('#absenden').addClass('button-theme-disable');
    }

};

Here are a demo: http://ift.tt/1Qg4KLF

What i'm doing wrong? Thanks for reading!




How to set another Items Visible when Checkbox is clicked?

I have written a frame in java swing . In it I have a checkbox . I want , that after clicking checkbox others Item will change it visibility. I was trying to do it as in code below but is not working as i wish .

public InFrm() {
    setTitle("In");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 450, 300);
    getContentPane().setLayout(new GridLayout(1, 1, 0, 0));
    seeMe=false;


    JSplitPane splitPane = new JSplitPane();
    splitPane.setResizeWeight(0.7);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    getContentPane().add(splitPane);

    JPanel panel = new JPanel();
    splitPane.setLeftComponent(panel);
    panel.setLayout(null);


     JPanel panel_1 = new JPanel();
    splitPane.setRightComponent(panel_1);

    panel_1.setLayout(null);

    JLabel lblKind= new JLabel("Kind");
    lblKind.setBounds(10, 8, 33, 14);
    lblKind.setVisible(seeMe);
    panel_1.add(lblKind);

    JComboBox ChoiceOd = new JComboBox();
    ChoiceOd.setBounds(53, 5, 28, 20);
    ChoiceOd.setVisible(seeMe);
    panel_1.add(ChoiceOd);


    // more items using seeMe


    JCheckBox chckbxOd = new JCheckBox("Od");
    chckbxOd.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
          seeOd();
          }
    });
    chckbxOd.setBounds(6, 150, 97, 23);
    panel.add(chckbxOd);



}

protected void seeOd() {
    if(seeMe){
        seeMe=false;
        }
    else
    {
        seeMe=true;
    }
}




has many through attributes challenge

I'm facing a challenge that I can't solve (tried multiple times and solved lots of errors but still ...)

Basically I have 3 models connected by a many-to-many through association:

class Student < ActiveRecord::Base
 has_many :likes, :dependent => :destroy
 has_many :recruiters, :through => :likes
 accepts_nested_attributes_for :likes, :allow_destroy => true
end

class Recruiter < ActiveRecord::Base
  has_many :likes 
  has_many :students, through: :likes
end

class Like < ActiveRecord::Base
  belongs_to :student
  belongs_to :recruiter
  accepts_nested_attributes_for :student
end

Now students should be able to tell recruiters if they can contact the student.

the view (students/show.html.erb) <--

So each student can like multiple recruiters and each recruiter can be liked by one or more students. A like has an attribute :match wich is a boolean. When this attribute is true I want to be able to list all students who like (:match = true) a certain recruiter.

This is the form I'm using to pass the :match attribute:

<div class="show">
<%= form_for [@student,@like]  do |f| %>
  <%= f.fields_for :likes do |p| %>
    <%= f.check_box :match %>
    <%= f.hidden_field :recruiter_id, :value => '20' %>
  <%end%><br>
      <%= f.submit "Let them contact me!" , class:"btn btn-primary" %> <br>
<% end %>

So if a student checks the checkbox it should create a record in the database with an updated like for the current student. But that's not happening :). It only creates a NEW record only with a :student_id (so without a :recruiter_id and :match)

Records in database <---

This is how my controllers look like:

class StudentsController < ApplicationController
  def show
    @student = Student.find(params[:id])
    @like = Like.new
  end
end

and

class LikesController < ApplicationController
before_action :find_student, only: [:new, :create, :update, :edit]

  def new
  end

  def create
    @student = Student.find(params[:student_id])
    @like = @student.likes.build(like_params)
    if @like.save
      redirect_to student_path(@student)
    else
      render :show
    end
  end

  private

  def like_params
    params.require(:like).permit(likes_attributes: [ :id, :match, :student_id, :recruiter_id])
  end

  def find_student
    @student = Student.find(params[:student_id])
  end
end

Anyone an idea on how to save the :recruiter_id and :match attribute to the database ?




How can I apply a CSS style to Html.CheckBoxFor in MVC 5

This seems like it should be so basic but for the life of me I can't get it working.

In my MVC 5 web app, I would like to show the user a list of layouts using checkboxes so the user can select whichever layouts are required.

I'm using an editor template, that gets called as such:

<table class="table">
<tr>
            <th> 
                @Html.DisplayName("Selected")
            </th>
            <th>
                @Html.DisplayNameFor(x => x.Layout)
            </th>
        </tr>
        @Html.EditorForModel()
</table>

Inside the template I use a helper for the checkbox.

<tr>
    <td>
         @Html.CheckBoxFor(x => x.IsSelected)
    </td>
    <td>    
        @Html.DisplayFor(x => x.Layout)
    </td>
</tr>

This all works fine, I can capture what the user has selected in the Post

What I cannot do however is apply any CSS styles to the checkbox.

What I have read is it should be a matter of:

@Html.CheckBoxFor(x => x.IsSelected, new { @class = "css-checkbox" })

This however causes the checkbox to not be rendered.

I have tried a few things such as wrapping the checkbox in a

<div class="checkbox"> 

but even though the checkbox is rendered, I cannot select any of the items.

Now there is hopefully just something simple I am doing or not doing?

Regards,

Neill




check box checked values getting only last value in android

When I toast value of assignbranch getting multiple elements in arraylist and checkbox is checked for last element only.

values in assignbranch are [a,b,c]. When toasting assignbranch why am I getting

[a,b,c]
[a,b,c,a,b,c]
[a,b,c,a,b,c,a,b,c]   

Code

public class BranchUserAdapter extends ArrayAdapter<BranchModel> {
    public ArrayList<BranchModel> EmployeesList;
    boolean[] itemChecked;
    LayoutInflater vi;
    int Resource;
    ViewHolder holder;
    private Context mContext;
    ArrayList<String>  assignbranch=new ArrayList<String>();;
    ArrayList<String>  branch=new ArrayList<String>();

    public BranchUserAdapter(Context context, int resource,    ArrayList<BranchModel> objects) {
        super(context, resource, objects);
        vi = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        Resource = resource;
        EmployeesList = objects;
        this.mContext = context;

    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        // convert view = design
        View v = convertView;

        if (v == null) {
            holder = new ViewHolder();
            v = vi.inflate(Resource, null);
            // new DownloadImageTask(holder.imageview).execute(actorList.get(position).getImage());
            holder.branchcheck = (CheckBox) v.findViewById(R.id.checkbox);
            holder.branch = (TextView) v.findViewById(R.id.branchuser);
            holder.branchcheck.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    CheckBox cb = (CheckBox) v;
                    BranchModel planet = (BranchModel) cb.getTag();
                    planet.setSelected(cb.isChecked());
                }
            });
            v.setTag(holder);
            holder.branchcheck.setTag(EmployeesList.get(position));
    } else {
        holder = (ViewHolder) v.getTag();
        ((ViewHolder) v.getTag()).branchcheck.setTag(EmployeesList.get(position));
        holder.branchcheck.setOnCheckedChangeListener(null);
    }
    BranchModel Employees = EmployeesList.get(position);
    final String sample=EmployeesList.get(position).getName();
    SessionManager session;
    session = new SessionManager(getContext());
    session.checkLogin();
    HashMap<String, String> user = session.getUserDetails();
    final String id = user.get(SessionManager.KEY_EMAIL);
    String tag_json_obj = "json_obj_req";
    String url = "http://ift.tt/1QmAgZD?"+id;
    StringRequest req = new StringRequest(Request.Method.GET,url,
    new Response.Listener<String>() {
        // final JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
        //"http://ift.tt/1LOXbYr", new Response.Listener<JSONObject>() {
            @Override
            public void onResponse(String response) {
                try {
                    JSONObject obj = new JSONObject(response);
                    JSONArray empjson = obj.getJSONArray("DDL");
                    for (int i = 0; i < empjson.length(); i++) {
                        //Getting json object
                        JSONObject json = empjson.getJSONObject(i);
                        //Adding the name of the student to array list
                        assignbranch.add(json.getString("name"));
                        if (sample.contains(assignbranch.get(i))){
                            holder.branchcheck.setChecked(true);
                        }*/
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                for(int i=0;i<assignbranch.size();i++){
                    for(int j=0;j<EmployeesList.size();j++){
                         if(assignbranch.get(i).equals(EmployeesList.get(j).getName())){
                        //that means object in second response exists in first response
                        holder.branchcheck.setChecked(true);
                    }
                }
            }
            Toast.makeText(getContext(), "hello"+assignbranch.toString(), Toast.LENGTH_SHORT).show();
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            error.getMessage();
            // hide the progress dialog
        }
    }) {

    };
    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(req, tag_json_obj);
    //   assignedBranch();

    holder.branch.setText(EmployeesList.get(position).getName());
    return v;
}
static class ViewHolder {
    public CheckBox branchcheck;
    public TextView branch;
}




dimanche 28 février 2016

extjs 6 checkbox group getValue

I need to post the values of selected checkboxes in a checkbox group to the server. Ultimately I am not worried about the checkbox name but just the list of input values.

How do I post these to the server? if I use getValue() I get an ext object features, using ext.encode on the object I get this

{"feature-3":"3","cfeature-5":"5","feature-7":"7",
"feature-10":"10","feature-12":"12","feature-13":"13",
"feature-15":"15","feature-18":"18"}

I don't care if the data is parsed before or after the post to the server but I need to be able to loop through the data in php and get 3..5..7 etc as the values when I loop through the data.

what is the best way to send checkboxgroup values to the server? I am using an ajax call like this :

 Ext.Ajax.request({
        scope: this,
        timeout: 1200000,
        url: './data/saveUsedFeatures.php',
        method: 'POST',
        params: {
 features: features
 },

I need to understand how to both send the data and process it in php.




First ListView Item is always checkd if another item is selected

I have a ListView with an Adapter extending the BaseAdapter and several items in my ListView. Every item has a CheckBox and this CheckBox can only be enabled and disabled from another Activity, so it is not possible to directly check the CheckBox in the ListView. However my problem is that if I check e.g. the third item, the first item is also checked. If I take a look into my database the first item should not be checked and if I debug this part, I do not see any reason why it should be checked. So what can be the reason that the first item gets checked as soon as I check another one? I heard that there is a problem with a ConvertView and CheckBoxes but I don't know how to solve this.

Let's go for some Code:

This is my Adapter.

public class ReportsAdapter extends BaseAdapter {

private List<Report> reports = new ArrayList<>();
private LayoutInflater inflater;
private Context context;

public ReportsAdapter(Context context, List<Report> reports) {
    this.reports = reports;
    this.context = context;
    inflater = LayoutInflater.from(this.context);
}

@Override
public int getCount() {
    return reports.size();
}

@Override
public Report getItem(int position) {
    return reports.get(position);
}

@Override
public long getItemId(int position) {
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;

    if (convertView == null) {
        convertView = inflater.inflate(R.layout.row_item_layout, parent, false);
        viewHolder = new ViewHolder(convertView);
        convertView.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) convertView.getTag();
    }

    Report currentReport = getItem(position);

    try {
        if (viewHolder.rowTvNr != null) {
            viewHolder.rowTvNr.setText(String.valueOf(currentReport.getReportNr()));
        }
        if (viewHolder.rowTvWeekFrom != null) {
            viewHolder.rowTvWeekFrom.setText(currentReport.getWeekFrom() + " ");
        }
        if (viewHolder.rowTvWeekTo != null) {
            viewHolder.rowTvWeekTo.setText(currentReport.getWeekTo());
        }

        viewHolder.checkBox.setClickable(false);
        if (viewHolder.checkBox != null && !viewHolder.rowTvNr.getText().equals("") || viewHolder.rowTvNr.getText() != null) {
            viewHolder.checkBox.setChecked(currentReport.isSent());
        } else {
            viewHolder.checkBox.setChecked(false);
        }
    } catch (Exception e) {
        Log.d("View Exception", "ListView Component is null" + e.toString());
    }
    return convertView;
}

private static class ViewHolder {
    TextView rowTvNr, rowTvWeekFrom, rowTvWeekTo;
    AnimateCheckBox checkBox;

    public ViewHolder(View item) {
        rowTvNr = (TextView) item.findViewById(R.id.rowTvWeekNr);
        rowTvWeekFrom = (TextView) item.findViewById(R.id.rowWeekFrom);
        rowTvWeekTo = (TextView) item.findViewById(R.id.rowWeekTo);
        checkBox = (AnimateCheckBox) item.findViewById(R.id.dailyCheckBox);
    }
}

}




how do i link a checkbox to a website

{{ slot.time }}
Booked Available

I have the following code. is there anyway that I can make it so that when the checkbox in clicked, it takes the user to another site.




Angular setting up ng-click on row but checkbox not working as desired

I have defined a simple row that has a name and a checkbox. I have the name and the checkbox bound to angular data, but I am now attempting to put in a row click that will reverse the value of the checkbox bound data, and still allow user to click the check box

this is my html

<div class="container" ng-controller="officeController" ng-cloak>
    <div class="row" ng-repeat="employee in office" ng-click="toggleStatus(employee)">
        <div class="col-md-1">
            <img ng-src="{{employee.imageUrl}}" style="width: 50px; height: 50px;"/>
        </div>
        <div class="col-md-7" ng-click="alert('hello')">
            {{employee.name}}
        </div>
        <div class="col-md-4">
        <input type="checkbox" ng-model="employee.inOffice" ng-click="toggleCheckbox($event)"/>
        </div>
    </div>
</div>

and this is my controller

officeModule.controller("officeController", function ($scope, officeRepository) {
    $scope.office = officeRepository.get(),
    $scope.toggleStatus = function (employee) {
        console.log('onClick' + new Date());
        console.log('Original: ' +employee.id + ', "' + employee.name + '", ' + employee.inOffice);
        employee.inOffice = !employee.inOffice;
        console.log('Modified: ' + employee.id + ', "' + employee.name + '", ' + employee.inOffice);
    };
    $.toggleCheckbox = function($event) {
        $event.stopPropagation();
    }
});

The employee object is data returned from a simple api call ( the officeRepository on the controller )

I have tried only having ng-checked on the checkbox, but I cant seem to get everything to work the way I want it

What am I doing wrong?




AppCompatCheckBox not working for below API 21

I am created dynamic checkbox with the following code:

xml:

                <LinearLayout
                    android:id="@+id/layout_checkbox"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="vertical">


                </LinearLayout>

.java:

LinearLayout ll = (LinearLayout) findViewById(R.id.layout_checkbox);

ll.removeAllViews();

for (int i = 0; i < 10; i++) {

    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);


    AppCompatCheckBox myCheckBox = new AppCompatCheckBox(getApplicationContext());
    myCheckBox.setText(i);
    myCheckBox.setTextColor(Color.parseColor("#FFFFFF"));
    myCheckBox.setHintTextColor(Color.parseColor("#FFFFFF"));
    myCheckBox.setTextSize(12);


    myCheckBox.setId(i);


    ll.addView(myCheckBox, lp);

}

Now from above code only LOLLIPOP version shows the checkbox with text. And for below LOLLIPOP version it shows only Text but not showing the checkbox.

Same thing work with all device if i will put the below code in xml file:

        <android.support.v7.widget.AppCompatCheckBox
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Testing"
                    android:buttonTint="@color/colorAccent"/>

But i cant defined the checkbox in xml as i have to created it dynamically.

Even setButtonTintList is not working for below LOLLIPOP

How can i show the Checkbox for below LOLLIPOP version with AppCompatCheckBox ?




How do I search certain row based on checkboxes and other forms

I have this tiny problem that I have been trying to solve for days now and in my anger I deleted everything I had yesterday. Not a smart choice.

Well, I have around 10 checkboxes on my site and I would like to use them to search in a row and get 1 correct row and display it on another page.

This is the form on index.php

<form action="country.php" method="post">
What continent do you want to visit?
<br>
<select name="continent[]">
   <option value="Europe">Europe</option>
   <option value="North America">North America</option>
   <option value="South America">South America</option>
   <option value="Asia">Asia</option>
   <option value="Australia">Australia</option>
   <option value="Africa">Africa</option>
</select>
<br><br>
What do you want to experience?
<br>

<input type="checkbox" name="action[]" value="Action"> Action
<input type="checkbox" name="romance[]" value="Romance"> Romance
<input type="checkbox" name="snow[]" value="Snow"> Snow
<input type="checkbox" name="music[]" value="Music"> Music
<input type="checkbox" name="festival[]" value="Festival"> Festival
<input type="checkbox" name="child[]" value="Child"> Child-Proof
<br><br>

<input type="submit" value="Find!">

And I want the program to find a row that suits the checkboxes, I will add more checkboxes in the future but while I am making the site I decided to just keep it short and simple.

Then I made the SQL like this:

id  /  country  /  background  /  description  /  checkbox  / continent /
1      Iceland    img/ice.jpg   some description  action,snow  europe
2      Denmark    img/den.jpg   some description  festival     europe

And I am looking for a way so when I click on find the program runs through my DB and finds the row which is best suited.

If I check in Action and Snow and choose Europe I will get Iceland on country.php or if I check festival and choose Europe I will get Denmark.

I have googled everything to the point of not knowing what I should google. Can someone please help me. I bet this is pretty simple but I'm not getting it!




Codename one Blue theme checkboxes in BoxLayout

I am using the CodenameOne blue theme ('shipped with' CodenameOne). I added checkboxes to a BoxLayout.Y container. When selecting one of the checkboxes, the checkbox is getting smaller and wider. I looked in the theme but I can't find out why. Tested on Android 4.4

I added two images to show what happens. In the first, METAR was checked (and unchecked I guess), in the second, TAF was checked.

After checking another one, the size of the checkbox selected before is normal again.

METAR was checked and unchecked and is smaller (height) and wider

TAF is checked and is smaller in height




Is there a generic way to avoid double labels on checkboxes with django-boostrap3?

I'm using django-boostrap3 with a for field in form loop. I'm looking for a generic way to have the checkboxes without the double labels:

Double labels

<form action="" method="POST" class="form-horizontal">{% csrf_token %}

    {% for field in form %}
        <div class="form-group{% if field.field.required %} required{% endif %}">
            <div class="col-lg-4 col-md-4 control-label">
                {% bootstrap_label field.label %}
            </div>
            <div class="col-lg-6 col-md-6">
                {% bootstrap_field field show_label=False form_group_class=None %}
            </div>
        </div>
    {% endfor %}

{% buttons %}
    <div class="control col-lg-11">
        <button type="submit" name="form_id_productitem"  class="btn btn-sm btn-success">
            {% trans "Submit" %}
        </button>
    </div>
{% endbuttons %}

This is what I want (specifically for checkboxes), preferably in the aformentioned loop:

enter image description here

I Would like the helptext where the second label is displayed. But it seems I have to let go of django-boostrap3 for this because it's not generic enough, and I like the balance between generic and custom.




samedi 27 février 2016

Alternative Way to Pass Checkbox Array to $_GET - Besides Square Braces

I understand that if I use a checkbox value of name[], then I will receive a data array on the server (when using PHP), named 'name[]'. This has worked fine for me, but I'm running into some URL sizes that could cause issues with less robust IE browsers and all the encoded square braces are killing me in this area, easily causing the URL length to be at least 4-6 times longer than what it could possibly be, if another way were available. Is there a reliable method using javascript (jquery syntax even better) to intercept a checkbox forms values and convert them into something like this:

"&checkboxarray=1-23-45-13-67"

I figure that on the other end I can easily explode $_GET['checkboxarray'] into an actual array and go from there as I usually do with matching the selection array against the options array, etc... I just don't know if it's possible or how to create alter the submit process.

Side note, isn't passing "name[]" to a URL non-standards compliant anyways? Every browser I've used auto encodes it, but not Mozilla, however it seems to work fine.




getJSON if checkbox is checked then uncheck

I got a function getBrandUrl() which fires getProducts().

If a checkbox is checked and the function is fired (for the second time, on a checked checkbox) the checkbox needs to be unchecked. So I can build the GET request without the value of that checkbox to filter out products by brand.

<input type="checkbox" name="brand[]" value="35890" onclick="javascript:getBrandUrl('35890');">
<a href="javascript:getBrandUrl('35890');" title="blabla" alt="blabla">blabla</a>

Clicking the a[href] (blabla) for the first time? then the checkbox needs to be checked and the GET request can be formatted. So if another checkbox or a[href] is clicked it appends to the URL and when it's clicked for the second time it needs to be removed.

function getBrandUrl(value)
        {
            getProducts("<?=$filterUrl?>", value, 'brand[]');
        }

function getProducts(url, value, type)
        {

            if($('input[type="checkbox"][value="' + value + '"]').is(':checked')) {
                $(this).attr('checked', 'false');
            } else {
                $(this).attr('checked', 'true');
            }

            var checked = '';
            $('input[name="' + type + '"]:checked').each(function() {
                checked += '&' + type + '=' + this.value;
            });

            $.getJSON(url + checked + "&json=true", function(data) {
                $('#productList').html('');

                $.each( data, function( key, val ) {
                    var product = formatProductHTML(val.ID, val.PRICE, val.TITLE, val.LINK);

                    $(product).appendTo('#productList');
                });
            });
        }

The problem is that when I click for the first time it will be uncheck right away so it won't be in the formatted GET request.

Any idea's how to solve this problem or does anyone know what i'm doing wrong here?




Show/Hide specific div if a checkbox has value of checked

I want to display/hide a div based on whether a certain checkbox is checked or unchecked.

Please note this is not about using jQuery .click or .change function. These don't work in my case.

What I am trying to do is that a certain div to display if a checkbox field has a value checked="checked", otherwise hide it.

I don't want to show/hide anything by default. I want to hide only if checkbox is unchecked and if it's checked, the div should always show (even on page load).

here is the link to Fiddle (.click approach and it does not work for me) http://ift.tt/1QjRBm4

You may notice that First Name checkbox is already checked but its adjacent div is still hidden.

Any help would be highly appreciated.

thanks




why is my app crashing (checkbox)

I'm trying to make a app in android studio(java) but i have a little problem whit my checkbox. every time when I unchecked the checkbox my app will crash. can somebody tell me what i am doing wrong.

.java file

package com.developer.sven.dartworkout20;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;

import java.util.ArrayList;

public class PreferenceDartThrow extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.preference_dart_throw_page);

    Intent preferenceDartThrowPageOpened = getIntent();
    String previousActivity = preferenceDartThrowPageOpened.getExtras().getString("Pref");
}

ArrayList<Integer> selection = new ArrayList<Integer>();

public void selectNumber(View view) {
    boolean numberChecked = ((CheckBox) view).isChecked();
    switch (view.getId()) {
        case R.id.number_D1:
            if (numberChecked) {
                selection.add(1);
            } else {
                selection.remove(1);
            }
            break;

        case R.id.number_D2:
            if (numberChecked) {
                selection.add(2);
            } else {
                selection.remove(2);
            }
            break;

        case R.id.number_D3:
            if (numberChecked) {
                selection.add(3);
            } else {
                selection.remove(3);
            }
            break;

        case R.id.number_D4:
            if (numberChecked) {
                selection.add(4);
            } else {
                selection.remove(4);
            }
            break;

        case R.id.number_D5:
            if (numberChecked) {
                selection.add(5);
            } else {
                selection.remove(5);
            }
            break;

.XML file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<CheckBox
        android:layout_width="wrap_content"
        android:layout_height="21dp"
        android:id="@+id/number_D1"
        android:onClick="selectNumber"
        android:layout_below="@+id/text_double"
        android:layout_centerHorizontal="true"
        android:checked="false" />


    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="21dp"
        android:id="@+id/number_D2"
        android:onClick="selectNumber"
        android:layout_below="@+id/number_D1"
        android:layout_centerHorizontal="true"
        android:checked="false"
        android:visibility="visible" />


    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="21dp"
        android:id="@+id/number_D3"
        android:onClick="selectNumber"
        android:layout_below="@+id/number_D2"
        android:checked="false"
        android:layout_centerHorizontal="true"
        android:visibility="visible" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="21dp"
        android:id="@+id/number_D4"
        android:onClick="selectNumber"
        android:layout_below="@+id/number_D3"
        android:checked="false"
        android:layout_centerHorizontal="true"
        android:visibility="visible" />

    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="21dp"
        android:onClick="selectNumber"
        android:layout_below="@+id/number_D4"
        android:checked="false"
        android:layout_centerHorizontal="true"
        android:id="@+id/number_D5"
        android:visibility="visible" />




HTML checkbox 'checked' property affects style?

I have a small sliding options control I'm coding in plain HTML and JS. it looks like this in chrome:

enter image description here

When none of the checkboxes is checked, it works as expected but when I check a checkbox, the alignment of the right icons breaks:

enter image description here

This happens both in chrome and firefox.
The live example is here:

http://ift.tt/24u8QHB

What the difference in style between a checked and unchecked checkbox?
How can I fix the misalignement?




html checkboxes to php

I have the following code for checkboxes in html:

    <label>Choose type of order :</label>

   <input type="checkbox" name="check_list[]" value="to1" > Energy Bar<br>
   <input type="checkbox" name="check_list[]" value="to2"> Tents <br>
   <input type="checkbox" name="check_list[]" value="to3"> Canned foods <br>

   </p>

And the php code is :

<?php
$t01=$_POST['check_list'][];

require("fpdf.php");
$pdf = new FPDF();
$pdf->AddPage();
foreach($_POST['check_list'] as $check) {
            echo $check; 

$pdf->Cell(50,10,"Total order :",1,0);
$pdf->Cell(50,10,"$t01",1,1);



    }
  }  
$pdf->Output();

}

?>

However when I run this on my server it shows me the following error:

Fatal error: Cannot use [] for reading in /Applications/XAMPP/xamppfiles/htdocs/demo/form.php on line 11

How can I correct this problem




checkbox directive using angularjs

I am trying to create a checkbox directive with angularjs.The code is here in JSFIDDLE

It works fine only with ng-model and text.

But if i add ng-true-value and ng-false value, it throw error as

nged2angular.js:12520 Error: [ngModel:constexpr] Expected constant expression for `ngTrueValue`, but saw `bindedTrueValue`.

Also i need to take the ng-change controller function inside the directive.




how to pass checkbox value from view to controller in laravel while clicking checkbox

Here is my code.. View

    <label>
<input class="i-check" name="amenity[]" type="checkbox" value="{{$amn->ht_amenity_id}}" />{{$amn->ht_amenity_name}}
     </label>

Controller

$purp = $_POST['amenity'];
    print_r($purp);

Here (In controller), I'm just trying to print the value

Please Some one help me.




CheckBox: Is it possible to change check symbol?

Is is possible to change the "tick" in checkbox to "X" on selection of it?

If yes, then please let me know how can i get it working using anything like HTML,CSS,Kendo UI?

Thanks!




.onCheckedListeners on multiple groups of checkboxes in Android Studio won't work

I have tried to have multiple groups of checkboxes where only one can be checked but on the attempt of implementing this functionality to a 2nd group of checkboxes the app crashes when i try to go to the activity containing those groups of checkboxes. The auton group of check boxes are working with only one able to be checked out of the 5 but even since I tried to add the same thing with the port_ ones I have had no luck.

    auton_nothing = (CheckBox)findViewById(R.id.nothing_cb);
    auton_touch= (CheckBox)findViewById(R.id.touchdefense_cb);
    auton_cross= (CheckBox)findViewById(R.id.cross_cb);
    auton_high= (CheckBox)findViewById(R.id.hg_cb);
    auton_low= (CheckBox)findViewById(R.id.lg_cb);

    auton_nothing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            auton_nothing.setChecked(b);
            auton_touch.setChecked(false);
            auton_cross.setChecked(false);
            auton_high.setChecked(false);
            auton_low.setChecked(false);
        }
    });
    auton_touch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            auton_nothing.setChecked(false);
            auton_touch.setChecked(b);
            auton_cross.setChecked(false);
            auton_high.setChecked(false);
            auton_low.setChecked(false);
        }
    });
    auton_cross.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            auton_nothing.setChecked(false);
            auton_touch.setChecked(false);
            auton_cross.setChecked(b);
            auton_high.setChecked(false);
            auton_low.setChecked(false);
        }
    });
    auton_high.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            auton_nothing.setChecked(false);
            auton_touch.setChecked(false);
            auton_cross.setChecked(false);
            auton_high.setChecked(b);
            auton_low.setChecked(false);
        }
    });
    auton_low.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            auton_nothing.setChecked(false);
            auton_touch.setChecked(false);
            auton_cross.setChecked(false);
            auton_high.setChecked(false);
            auton_low.setChecked(b);
        }
    });
    port_na= (CheckBox)findViewById(R.id.portc_na_cb);
    port_na.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            port_na.setChecked(b);
            port_attempt.setChecked(false);
            port_diff.setChecked(false);
            port_easy.setChecked(false);
        }
    });
    port_attempt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            port_na.setChecked(false);
            port_attempt.setChecked(b);
            port_diff.setChecked(false);
            port_easy.setChecked(false);
        }
    });
    port_diff.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            port_na.setChecked(false);
            port_attempt.setChecked(false);
            port_diff.setChecked(b);
            port_easy.setChecked(false);
        }
    });
    port_easy.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            port_na.setChecked(false);
            port_attempt.setChecked(false);
            port_diff.setChecked(false);
            port_easy.setChecked(b);
        }
    });
    port_attempt= (CheckBox)findViewById(R.id.portc_attempted_cb);
    port_diff= (CheckBox)findViewById(R.id.portc_difficult_cb);
    port_easy= (CheckBox)findViewById(R.id.portc_easy_cb);




vendredi 26 février 2016

PHP - Using bootstrap modal as a confirmation to delete multiple selected checkboxes

I have data retrieved from database and populated inside a table. For each rows there is a checkbox where the user will be able to select multiple rows and delete it. How can I make it in such a way that when the user click the delete button after checking the checkbox on the table, a bootstrap modal will appear as a confirmation to delete those selected rows. The user will then click the confirm button on the bootstrap modal to delete the record from the database. Currently when I click the confirm button on the bootstrap modal it does not delete the record on the database.

index.php (PHP)

<?php
include_once 'configuration.php';

session_start();

$message = "";

if((isset($_SESSION['username']) == ""))
{
    header("Location: index.php");
}

$sql = "SELECT id, title FROM books";
$query = mysqli_query($db, $sql);
?>

index.php (HTML)

<div class="content">
            <form id="booksForm" action="" method="POST">
                    <table id="booksTable" class="col-md-12 table-bordered table-striped table-condensed cf">
                        <thead class="cf">
                            <tr>
                                <th><input type="checkbox" class="chkAll" value="" /></th>
                                <th>#</th>
                                <th>Title</th>
                                <th>Action</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php 
                                while($result = mysqli_fetch_array($query))
                                {
                                    $html = '<tr>
                                                <td data-title="">
                                                    <input type="checkbox" name="chkDelete[]" value="' . $result['id'] . '">
                                                </td>
                                                <td data-title="#">' . $result['id'] . '</td>
                                                <td data-title="Title">' . $result['title'] . '</td>
                                                <td data-title="Action">
                                                    <a href="edit.php?id=' . $result['id'] . '">Edit</a>
                                                </td>
                                             </tr>';

                                    echo $html;
                                }
                            ?>
                        </tbody>
                    </table>

                <input type="button" id="btnDelete" value="Delete" data-toggle="modal" data-target="#confirmDelete"/>
                <div class="message"><?php echo $message;?></div>
            </form>

            <div id="confirmDelete" class="modal fade" role="dialog">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                            Delete selected data?
                        </div>

                        <div class="modal-body">
                            Click confirm to delete data permanently.
                        </div>

                        <div class="modal-footer">
                            <button class="btn btn-success" id="btnConfirm">Confirm</button>
                            <button type="button" class="btn btn-danger" data-dismiss="modal">Cancel</button>
                        </div> <!--//END modal-footer-->
                    </div> <!--//END modal-content-->
                </div> <!--//END modal-dialog-->
            </div> <!--//END confirmDelete-->
        </div> <!--//END content-->
<script type="text/javascript" src="resource/js/bootstrap.min.js"></script>
<script>
    $('#btnConfirm').click(function() {
        $.ajax({
            type: "POST",
            url: "deleteBooks.php",
            data: $('confirmDelete').serialize(),
            success: function(msg){
                alert("success");
                $("#confirmDelete").modal('hide'); 
            },
            error: function(){
                alert("failure");
            }
        });
    });
</script>

deleteBooks.php (PHP)

<?php
if(isset($_POST['btnConfirm'])) 
{
    $checkbox = isset($_POST['chkDelete']) ? $_POST['chkDelete'] : array();

    $id = 0;

    for($i=0;$i<count($checkbox);$i++)
    {
        $id = $checkbox[$i];

        $deleteQuery = "DELETE FROM books WHERE id='$id'";
        $DeleteQueryExec = mysqli_query($db, $deleteQuery);
    }
}
?>




Check Box selected is displayed wrongly

I am working on a screen where i am populating a list view using base adapter.Each row of list view contains a circular image view,Text View and Check box .On clicking single tick on toolbar ,i am displaying the id of user corresponding to checked button But it is displayed wrongly.I am implementing the following screen:

Screenshot

1.Bean_Friends

    public class Bean_Friends {
    private String name, url, extension, friendsID;
    private String friendSelected = "false";

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getExtension() {
        return extension;
    }

    public void setExtension(String extension) {
        this.extension = extension;
    }

    public String getFriendsID() {
        return friendsID;
    }

    public void setFriendsID(String friendsID) {
        this.friendsID = friendsID;
    }

    public String getFriendSelected() {
        return friendSelected;
    }

    public void setFriendSelected(String friendSelected) {
        this.friendSelected = friendSelected;
    }
}

2.Adapter_Friends_Group.java

    public class Adapter_Friends_Group extends BaseAdapter {
    private Context context;
    public List<Bean_Friends> listBeanFriends;
    private LayoutInflater inflater;
    private ApiConfiguration apiConfiguration;
    private Bean_Friends bean_friends;


    public Adapter_Friends_Group(Context context, List<Bean_Friends> listBeanFriends) {
        this.context = context;
        this.listBeanFriends = listBeanFriends;
    }

    @Override
    public int getCount() {
        return listBeanFriends.size();
    }

    @Override
    public Object getItem(int i) {
        return listBeanFriends.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (inflater == null) {
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
        if (view == null) {
            view = inflater.inflate(R.layout.feed_item_friends, null);
        }

        //finding different views
        ImageView pic = (ImageView) view.findViewById(R.id.friendsImage);
        TextView txtName = (TextView) view.findViewById(R.id.nameFriends);
        CheckBox chkFriends = (CheckBox) view.findViewById(R.id.chkFriends);

        bean_friends = listBeanFriends.get(i);
        String name = bean_friends.getName();
        String url = bean_friends.getUrl();
        String extension = bean_friends.getExtension();
        apiConfiguration = new ApiConfiguration();
        String api = apiConfiguration.getApi();
        String absolute_url = api + "/" + url + "." + extension;

        //loading image into ImageView                                                                                                                                            iew
        Picasso.with(context).load(absolute_url).error(R.drawable.default_avatar).into(pic);

        //Setting name in the textview
        txtName.setText(name);

        //If check box is checked,then add true to bean else add false to bean
        if (chkFriends.isChecked()) {
            bean_friends.setFriendSelected("true");
        } else {
            bean_friends.setFriendSelected("false");
        }


        chkFriends.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                CheckBox cb = (CheckBox) view;
                if (cb.isChecked()) {
                    bean_friends.setFriendSelected("true");
                    Toast.makeText(context, "Check Box is checked : " + cb.isChecked(), Toast.LENGTH_SHORT).show();
                } else {
                    bean_friends.setFriendSelected("false");
                }
            }
        });


        return view;
    }
}

3. Code of Activity containing view

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();
    MenuInflater menuInflater = getMenuInflater();
    menuInflater.inflate(R.menu.menu_new_group, menu);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.createGroup:
            createNewGroup();
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}


public void createNewGroup() {
    Toast.makeText(NewGroupActivity.this, "clicked", Toast.LENGTH_SHORT).show();
    List<Bean_Friends> listBeanFriends = new ArrayList<>();
    //Log.e("Size of listbeanFriends", String.valueOf(listBeanFriends.size()));

    listBeanFriends = adapter_friends_group.listBeanFriends;
    //  Log.e("Size of adapter_friends", String.valueOf(adapter_friends_group.listBeanFriends.size()));
    Log.e("Size of listbeanFriends", String.valueOf(listBeanFriends.size()));
    for (int i = 0; i < listBeanFriends.size(); i++) {
        Log.e("Loop Working", String.valueOf(i));
        Bean_Friends bean_friends = listBeanFriends.get(i);
        String friendID = bean_friends.getFriendsID();
        String friendSelected = bean_friends.getFriendSelected();
        String friendName = bean_friends.getName();
        Log.e("FriendsName", friendName);
        Log.e("FriendID", friendID);
        Log.e("friendSelected", friendSelected);
        if (friendSelected.equals("true")) {
            Toast.makeText(NewGroupActivity.this, friendID, Toast.LENGTH_SHORT).show();
        } else {
            // Toast.makeText(NewGroupActivity.this,"true",Toast.LENGTH_SHORT).show();
        }
    }
}




Angularjs: Common checkbox filter for multiple columns in ng-repeat table

I have multiple checkboxes corresponding to each column of ng-repeat table, I want to implement a global filter to filter multiple columns in table. Is it possible to declare global filter and at the same time it should filter list before pagination.

My problem is, I couldnt declare common global filter which can be used by multiple checkboxes related to different columns




Add D3 Element to persistent checkbox state after page refresh

I want to add D3 Element to already persistent checkboxes after page refresh. If i click into a checkbox a line should appear in my graph visualization and stay after the page refresh like the checkmarks.

Here is the code from the first part:

 <div>
  <label for="option1">150°C</label>
  <input onclick="150();" type="checkbox" id="option1">
</div>
<div>
  <label for="option2">125°C</label>
  <input onclick="125();" type="checkbox" id="option2">
</div>
<div>
  <label for="option3">85°C</label>
  <input onclick="85();" type="checkbox" id="option3">
</div>
  <div>
  <label for="option3">-40°C</label>
  <input onclick="40();" type="checkbox" id="option4">
</div>
  <div>
  <label for="option3">-60°C</label>
  <input onclick="60();" type="checkbox" id="option5">
</div>

the script part:

function handleButtonClick(button){
    if ($(button).text().match("Check all")){
      $(":checkbox").prop("checked", true)
    } else {
      $(":checkbox").prop("checked", false)
    };
    updateButtonStatus();
  }
  function updateButtonStatus(){
    var allChecked = $(":checkbox").length === $(":checkbox:checked").length;
    $("button").text(allChecked? "Uncheck all" : "Check all");
  }
  function updateCookie(){
    var elementValues = {};
    $(":checkbox").each(function(){
      elementValues[this.id] = this.checked;
    });
    elementValues["buttonText"] = $("button").text();
    $.cookie('elementValues', elementValues, { expires: 7, path: '/' })
  }
  function repopulateFormELements(){
    var elementValues = $.cookie('elementValues');
    if(elementValues){
      Object.keys(elementValues).forEach(function(element) {
        var checked = elementValues[element];
        $("#" + element).prop('checked', checked);
      });
      $("button").text(elementValues["buttonText"])
    }
  }
  $(":checkbox").on("change", function(){
    updateButtonStatus();
    updateCookie();
  });
  $("button").on("click", function() {
    handleButtonClick(this);
    updateCookie();
  });
  $.cookie.json = true;
  repopulateFormELements();

and i want to add to the checkboxes some persistent lines for my temperature graph like this one:

function 150(){ svg.append("svg:line") .attr("id", "HTS1") .attr("x1", 0) .attr("x2", width) .attr("y1", 112) .attr("y2", 112) .attr("stroke-width", 2) .attr("stroke", "brown"); }

I know i need JQuery cookie, but how to use them with functions. So my lines retain after a page refresh to like the checkboxes.

Can someone help me?




Checkbox insert 1 or 0 into SQL database

I am setting up a system that has many answers from a question. Therefore the user can click a button to dynamically add answers. I want the user to be able to tick a checkbox next to the answers which are correct and then insert this into the database (1 being correct).

Here is what I have:

HTML:

<div id="answers">
 <label class="answer">
  Answer:
   <input type="text" name="ab_name[]" value=""/>
    Correct?
   <input type="checkbox" name="ab_correct[]" value="0">
 </label>
</div>

PHP

$ab_name = $_POST['ab_name'];
$ab_correct = $_POST['ab_correct'];

$sql = "INSERT INTO answers_bank (`ab_name`, `ab_correct` ) VALUES (:ab_name, :ab_correct )";
$stmt = $db->prepare($sql);

foreach ($_POST['ab_name'] as $ab_name) {
$stmt->bindValue(':ab_name', $ab_name);
$stmt->bindValue(':ab_correct', $ab_correct);
$stmt->execute();
}

Like this:

This should give more of an idea:

The SQL inserts the ab_name but the ab_correct is ALWAYS set to 1 if it is ticked or unticked. Any guidance on this please?




How to create an array in jquery when checkbox is clicked ?

I have a checkbox for brands and a check box for prices. Now if a user clicks on the check box I want an array of brand_ids and an array of prices.

<div class="left-filters__inner--block">
                                <ul class="filter-data filter-data-brands" id="brands_list">
                                    @foreach(App\Brand::all() as $brand)
                                        <li>
                                            <label for="{{$brand->name}}" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
                                                    <input type="checkbox" name="brands[]" id="{{$brand->name}}" class="mdl-checkbox__input"  data-value="{{$brand->id}}">
                                                    <span class="mdl-checkbox__label">{{$brand->name}}</span>                       
                                            </label>
                                        </li>
                                    @endforeach
                                </ul>
                            </div>

price view with checkbox

<div class="left-filters__inner--block">
                                <ul class="filter-data filter-data-price" id="price_list">

                                    <li>
                                        <label for="less-20" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
                                            <input type="checkbox" id="less-20" class="mdl-checkbox__input" name="price" data-value="0,20">
                                            <span class="mdl-checkbox__label">Less than 20</span>
                                        </label>
                                    </li>
                                    <li>
                                        <label for="21-50" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
                                            <input type="checkbox" id="21-50" class="mdl-checkbox__input" name="price" data-value="21,50">
                                            <span class="mdl-checkbox__label">21  -  50</span>
                                        </label>
                                    </li>
                                    <li>
                                        <label for="51-100" class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect">
                                            <input type="checkbox" id="51-100" class="mdl-checkbox__input"  name="price" data-value="51,100">
                                            <span class="mdl-checkbox__label">51  -  100</span>
                                        </label>
                                    </li>

Now when user clicks on the checkbox a particular brand or price I want an array which looks like this.

Array
    (
        [brand_id] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

        [price] => Array
        (
            [0] => 0,1000
            [1] => 1000,2000
        )

    )

I want to achieve this using jquery. Please assists




Polymer - How to listen to a

I tried to handle with some polymer-elements and I didn't understand the event-handling in that case. Is their anyone who could try to explain it by the example below?

<html>
...
   <body>
        <table style="border: 1px solid black;">
            <tr>
                <td><paper-checkbox ..?..>Checkbox 1</paper-checkbox></td>
            </tr>
            <tr>
                <td><paper-checkbox noink>Checkbox 2</paper-checkbox></td>
            </tr>
            <tr>
                <td><paper-checkbox noink>Checkbox 3</paper-checkbox></td>
            </tr>
        </table>
  </body>
</html>
<script>
 ..?..
</script>

Thanks for your help!




Symfony2, Twig and Checkboxes custom twig template

I am using bootstrap 3 for my template and I am aware of the templating that exist within the Symfony Twig Bridge. Below is what I would like to have in the end.

enter image description here

Where I have a grey area is where I would like to have my label at 90% alignment.

Below is what I currently have:

<div class="form-group">
  <div id="campaign_channel" class="col-xs-6">
    <input id="campaign_channel_1" type="checkbox" value="1" name="campaign[channel][]">
    <label for="campaign_channel_1">Facebook</label>
    <input id="campaign_channel_2" type="checkbox" value="2" name="campaign[channel][]">
    <label for="campaign_channel_2">Twiiter</label>
    <input id="campaign_channel_3" type="checkbox" value="3" name="campaign[channel][]">
    <label for="campaign_channel_3">LinkedIn</label>
    <input id="campaign_channel_4" type="checkbox" value="4" name="campaign[channel][]">
    <label for="campaign_channel_4">Instagram</label>
    <input id="campaign_channel_5" type="checkbox" value="5" name="campaign[channel][]">
    <label for="campaign_channel_5">Youtube</label>
   </div>
  </div>

Below is what I would like to have:

<div class="form-group">
  <div id="campaign_channel" class="checkbox col-xs-6">
     <div class="checkbox-label">Channel(s)</div>
     <div class="checkbox-clmn-1">
     </div>
     <div class="checkbox-clmn-2">
     </div>
  </div>
</div>

If, as shown in the example, we have 5 checkboxes I want to split any number of checkboxes by using the multiples of three. Say have the first three checkboxes in the first column in a case where total number is odd and then if even then checkboxes should be spraed equally in both checkbox columns.

Where exactly can I create this custom template "fields.html.twig" in my Symfony application so that I can actually play around with this idea?




How to access the check box displayed using adapter in the activity containing list view

I am working on the following screen:

New Group screen

The friends list is displayed by populating listview using Base Adapter.

Adapter

  public class Adapter_Friends_Group extends BaseAdapter {
    private Context context;
    private List<Bean_Friends> listBeanFriends;
    private LayoutInflater inflater;
    private ApiConfiguration apiConfiguration;

    public Adapter_Friends_Group(Context context, List<Bean_Friends> listBeanFriends) {
        this.context = context;
        this.listBeanFriends = listBeanFriends;
    }

    @Override
    public int getCount() {
        return listBeanFriends.size();
    }

    @Override
    public Object getItem(int i) {
        return listBeanFriends.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (inflater == null) {
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
        if (view == null) {
            view = inflater.inflate(R.layout.feed_item_friends, null);
        }

        //finding different views
        ImageView pic = (ImageView) view.findViewById(R.id.friendsImage);
        TextView txtName = (TextView) view.findViewById(R.id.nameFriends);
        CheckBox chkFriends = (CheckBox) view.findViewById(R.id.chkFriends);

        final Bean_Friends bean_friends = listBeanFriends.get(i);
        String name = bean_friends.getName();
        String url = bean_friends.getUrl();
        String extension = bean_friends.getExtension();
        apiConfiguration = new ApiConfiguration();
        String api = apiConfiguration.getApi();
        String absolute_url = api + "/" + url + "." + extension;

        //loading image into ImageView                                                                                                                                            iew
        Picasso.with(context).load(absolute_url).error(R.drawable.default_avatar).into(pic);

        //Setting name in the textview
        txtName.setText(name);

        chkFriends.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
                Log.e("Checkboxxxxxxxxxx", "Clicked");
                if (isChecked) {
                    bean_friends.setFriendSelected("true");
                    Log.e("Checkbox", "Checked");
                } else {
                    bean_friends.setFriendSelected("false");
                    Log.e("Checkbox", "UnChecked");
                }
                listBeanFriends.add(bean_friends);
            }
        });
        return view;
    }
}

When the check box is clicked,I am saving a string value as true in the Bean.

Bean

public class Bean_Friends {
    private String name, url, extension, friendsID;
    private String friendSelected;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getExtension() {
        return extension;
    }

    public void setExtension(String extension) {
        this.extension = extension;
    }

    public String getFriendsID() {
        return friendsID;
    }

    public void setFriendsID(String friendsID) {
        this.friendsID = friendsID;
    }

    public String getFriendSelected() {
        return friendSelected;
    }

    public void setFriendSelected(String friendSelected) {
        this.friendSelected = friendSelected;
    }
}

Now inside the activity containing list view,In want to access the id of the friend whose check box is checked on clicking single tick on the Top Toolbar.

Following method is used on clicking single tick:

public void createNewGroup() {
    Toast.makeText(NewGroupActivity.this, "clicked", Toast.LENGTH_SHORT).show();
    listBeanFriends = new ArrayList<>();
    for (int i = 0; i < listBeanFriends.size(); i++) {
        Log.e("Loop Working", "-------------");
        Bean_Friends bean_friends = listBeanFriends.get(i);
        String friendSelected = bean_friends.getFriendSelected();
        String friendID = bean_friends.getFriendsID();
        Log.e("FriendID", friendID);
        if (friendSelected.equals("true")) {
            Toast.makeText(NewGroupActivity.this, friendID, Toast.LENGTH_SHORT).show();
        } else {
            // Toast.makeText(NewGroupActivity.this,"true",Toast.LENGTH_SHORT).show();
        }
    }
}

But this is mot working for me .I want to access the id of friends whose check box is checked on clicking single tick.Please help me to fix the issue.




jeudi 25 février 2016

How to use jquery to get classes starting with a value and adding events to chekcboxes in each of the classes

I have a set of classes all beginning with marg-. Something like the pattern below:

'<div class="marg-1 row-">'+
                '<p class="subject-math col-6">Mathematics</p>'+
                '<div class="check-div col-1" > <input type="checkbox" class="math-check"  /></div>'+
           '</div>'+
           '<div class="marg-2 row-">'+
                '<p class="subject-eng col-6">English</p>'+
                '<div class="check-div col-1" > <input type="checkbox" class="eng-check"  /></div>'+
           '</div>'+
           '<div class="marg-3 row-">'+
                '<p class="subject-phy col-6">Physics</p>'+
                '<div class="check-div col-1" > <input type="checkbox" class="phy-check"  /></div>'+
           '</div>'  

I want to write jquery code that will locate them all and add an onselect event to the checkboxes in them.

How do I do this?




WP Multiple Checklist Warnings & Errors

I've been trying to fix this error for a while with no luck. Maybe is the context of my program which makes it very challenging for me.

I created a simple plugin (settings API / Page Options) for Wordpress in which the user has access to multiple checkboxes to initialize the TinyMCE editor. It saves the selected checkboxes in an $options['array'] and then I use that data in my function to initialize the TinyMCE Editor. Everything works great with the exception of the Notices, Warnings outputted in my front end.

Here is how my Settings Page is built (it has multiple instances of this, but this should give an idea of the basic functionality.)

function mmm_select_providers(  ) {

    $options = get_option( 'mmm_settings' );

    $buttons = array(
        'Format' => 'formatselect',
        'Bold' => 'bold',
        'Italic' => 'italic',
        'Underline' => 'underline',
        'Superscript' => 'superscript',
        'Align Left' => 'alignleft',
        'Align Center' => 'aligncenter',
        'Align Right' => 'alignright',
        'Bullet List' => 'bulletlist',
        'Number List' => 'numberlist',
        'Link' => 'link',
        'Unlink' => 'unlink'
    );

    foreach ($buttons as $key => $value) { ?>
        <input name="mmm_settings[mmm_select_providers_check][]" type="checkbox" value='<?php echo $value; ?>' <?php if((isset($options['mmm_select_providers_check']) && in_array($value, $options['mmm_select_providers_check']))) { echo "checked"; } ?>/>
        <label for="<?php echo $value ?>"><?php echo $key; ?></label>
    <?php }
}

Keep in mind some "checkbox" won't be selected by the user. After saving the data I can then go to my TinyMCE function and gather the $options['mmm_select_providers_check'] and perform some basic string operations to format the output the way I need it:

$global_toolbar = implode(', ', array_values($options['mmm_select_providers_check']));

It gives me the correct output with no errors and it works in the TinyMCE function (it initializes it with the selected toolbar buttons). Here is the snippet:

$in['toolbar1'] = $providers_toolbar;

Locally, the plugin works fine but when I deploy to Dev -- it gives me a string of notices and warnings such as:

Notice: Undefined index: 

Warning: array_values() expects parameter 1 to be array, null given in

Warning: implode(): Invalid arguments passed in 

Warning: array_values() expects parameter 1 to be array, null given in

And so on ! Keep in mind I'm using a lot of instances of this sample code, gathering info for many WP Editors. The code posted is just to establish context.

Does this makes sense? I tried everything -- filter_array, isset and other suggestions -- but I can't seem to get rid of the errors. What I think is happening is that the checkbox is saving data even if the checks are not selected and then causing some conflict.

Please let me know if anybody can help! I'm not that new with PHP but I am new at WP Plugins / Settings API / Page Options

Thanks!




Update a checkbox value in table correctly in JSP

I am trying to put an edit in my processing that sets a checkbox field 'checked' in a table. here is my layout of the table:

      <table id="checkedTable" >
         <thead>
           <tr>
            <th>  SEL</th>
            <th>Schedule Number</th>
            <th>Contract Year</th>
            <th>Creation Date</th>
            <th>Num of Pay Recs</th>
            <th>Schedule Total</th>
            <th>Status</th>
            <th>Status Date</th>
            <th>Approval ID</th>
          </tr>
          </thead>
            <tbody style="overflow-y: scroll; ">
               <c:forEach  var="row" items="${Updresults}">
               <c:set var="sched" value="${row.getSCHEDULE_NUMBER()}" />
               <c:set var="eftyear" value="${row.getEFT_CONTRACT_YEAR()}" />
               <c:set var="EFTstatus" value="${row.getSTATUS()}" />
               <c:set var="schedcombo"  value="${sched}${eftyear}" />
               <fmt:formatNumber var="schedTotl" value="${row.getTOTAL_AMOUNT()}" pattern="$##,###,##0.00"/>
               <tr>
                  <td align="center">  
                  <input style="width:50px;" type="checkbox" id="selectedSched" 
                         name="selectedSched" 
                         value="<c:out value="${schedcombo}"/>"/>  
                 </td> 

                </c:forEach>

         </tbody>
      </table>

Here is my javascript code in the window onLoad processing:

     for(var i=0; i<updateformID.selectedSched.length; i++)
           {

              var checkSchedule = document.getElementById("checkedTable").rows[i + 1].cells[1].innerHTML;
              var checkYear = document.getElementById("checkedTable").rows[i + 1].cells[2].innerHTML;
              $('#holdLineSchedule').val(checkSchedule); 

              for(var j=0; j<selectObject.listSched.length; j++)
                  {
                     var itemSchedule =  selectObject.listSched[j].schedulekey;
                     var itemContractYear = selectObject.listSched[j].contractkey ;
                     if (checkSchedule === itemSchedule)
                        {
                          alert("Schedule Number" + itemSchedule + " is found in process") ;
                          j = selectObject.listSched.length + 1  ;

                          document.getElementById("selectedSched").rows[i + 1].checked = true;

                         }

              }

The processing is having a problem with trying to update the 'checked' property to 'true' with an error on the 'rows[i + 1]' part. Am I missing something in the document.getElementbyID to use the 'checked' attribute.

I know one way of figuring this out is to use the 'name' of the checkbox field but then I have a problem with my servlet because I am doing a 'request.getParameterValues("selectedSched")' to loop through all the records checked. I don't know if there is a way to use 'getParameterValues' by ID instead of the name in servlet.

Thanks again.




Mapbox personalized icons with cluster and filter checkbox

I have created a map using mapbox. I add icons from an Url and a type of "filter". But I want to add a marker cluster and in and also that the filter function with checkbox to select more than one option.

http://ift.tt/21uil7b

This is my example. I'll tried with the Leaflet marker cluster but... I'm totally new with code then, I don´t know in what place I should put the cluster code.

I think now, the most important form me is the checkbox for the filters. I tried to make put "true" or "false" to certain values in the properties of the icon and this at final. But aren´t checkboxes :(

myLayer.on('layeradd', function(e) {
    var marker = e.layer;
    var feature = marker.feature;

    var images = feature.properties.images
    var slideshowContent = '';

marker.setIcon(L.icon(feature.properties.icon));
    for(var i = 0; i < images.length; i++) {
        var img = images[i];
    }
    var popupContent =  '<div id="' + feature.properties.id + '" class="popup">' +
                            '<h2>' + '<p align=center>'+ feature.properties.title + '</p>'+'</h2>' +
                            '<h5>' + feature.properties.description +'</h5>'

                        '</div>';

    marker.bindPopup(popupContent,{
        closeButton: false,
        minWidth: 400
    });

});



myLayer.setGeoJSON(geoJson)
.addTo(map);

$('.menu-ui a').on('click', function() {
      var filter = $(this).data('filter');
    $(this).addClass('active').siblings().removeClass('active');
    myLayer.setFilter(function(f) {

        return (filter === 'Development') ? true : f.properties[filter] === true;
    });
    return false;
});

Thanks and have a nice day! :)




checkbox value in codeigniter

How can I check in codeigniter if a checkbox is checked or not? I need to do this to set a custom message for an error. I try this:

public function misure_validation() {
  $this->load->library('form_validation');
  $this->form_validation->set_rules('accetta_misure','accetta','required|md5|trim|callback_convalida_tos');
  // la funzione run ritorna un true solo se le regole sopra sono verificate
  if ($this->form_validation->run() == true) {
    $this->misure_db();
  } else {
    $this->nuovocosplay(); //ritorna alla schermata delle misure
  }
}

public function convalida_tos()
{
  $check = $this->input->post('accetta_misure')?1:0;
  if ($check==1) {
     return true;
  } else {
    $this->form_validation->set_message('convalida_tos', 'devi accettare i termini e le condizioni della commissione.');
    return false;
  }
}

of course I've set the checkbox in the view in this way

<?php echo form_checkbox('accetta_misure','1', FALSE); ?>

thank you




Checkbox prompt in Report Builder 3.0

I want to set up several prompts as a checkboxes in Report Builder 3.0. Is this possible? I've set up prompts for drop down lists, textboxes, date paramters, etc. But I've never set one up as a checkbox. Is this possible? How is it done? Thanks for the help.




Javascript looping through Page elements to change states?

This is relatively simple, but I'm missing something. I have 10 checkboxes on a page, in a table in a form. They all have names and id's of add0, add1, add2, etc. I wanted to build a "check/uncheck all" checkbox, but my code doesn't seem to be working. On firefox, using firebug, but it can't seem to follow the script execution.

function checkboxprocess(current)
{
    for (i = 0; i < 10; i++)
    {
        if (current.checked)
        {
            document.getElementById("add" + i).checked = true;
        }
        else
        {
            document.getElementById("add" + i]).checked = false;
        }
    }
}

Checkbox:

echo "Select All: <input type=\"checkbox\" name=\"add\" id=\"add\" value=1 onChange=\"checkboxprocess(this)\"><br>";




Adding constraints programmatically to a M13CheckBox

I'm trying to incorporate a M13CheckBox into one of my views. I have successfully created one and placed it inside a view I call 'contentView.' The problem comes when I try to set constraints for the checkBox in the contentView.

When I add constraints, the checkBox moves but it becomes unresponsive at the same time.

Here is my code:

override func viewDidLoad() {
    super.viewDidLoad()

    //create the checkBox

    let size = CGRectMake(0, 0, 18, 18)
    let checkBox = M13Checkbox.init(frame: size)
    checkBox.strokeColor = UIColor.init(red: 189, green: 170, blue: 170)
    checkBox.checkColor = UIColor.init(red: 74, green: 74, blue: 74)
    checkBox.tintColor = UIColor.init(red: 189, green: 170, blue: 170)
    checkBox.translatesAutoresizingMaskIntoConstraints = false

    //add to contentView which is already setup in the storyboard

    contentView.addSubview(checkBox)

    //add the constraints

    let views = ["view": contentView, "checkBox": checkBox]
    let horizontalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-20-[checkBox]", options: NSLayoutFormatOptions.AlignAllCenterY, metrics: nil, views: views)
    contentView.addConstraints(horizontalConstraints)
    let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|-10-[checkBox]", options: NSLayoutFormatOptions.AlignAllCenterX, metrics: nil, views: views)
    contentView.addConstraints(verticalConstraints)
}

So this all works but I can't actually click the checkBox when it apperars on screen.

So how could I move the checkBox while keeping it responsive?

I think it has something to do with me adding the checkBox.translatesAutoresizingMaskIntoConstraints = false. But when I don't have this the constraints don't work.

Any help would be appreciated. Thanks!




all the checkboxes are getting checked on clicking a single checkbox

i have a list of checkboxes in my angularjs code. when i click a checkbox, all the checkboxes get activated. How can i check only a single checkbox?

here is my code

<!DOCTYPE html>
<html>
<script src="http://ift.tt/1Mrw6cj"></script>
<body>

<div ng-app="myApp" ng-controller="namesCtrl">

<p>Type a letter in the input field:</p>
<form action="">
<p><input type="checkbox" ng-model="alpha" value="a">a</p>
<p><input type="checkbox" ng-model="alpha" value="b">b</p>
<p><input type="checkbox" ng-model="alpha" value="c">c</p>
<p><input type="checkbox" ng-model="alpha" value="d">d</p>
<p><input type="checkbox" ng-model="alpha" value="e">e</p>
<p><input type="checkbox" ng-model="alpha" value="f">f</p>
</form>
<ul>
  <li ng-repeat="x in names | filter:alpha">
    {{ x }}
  </li>
</ul>

</div>

<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
    $scope.names = [
        'Jani',
        'Carl',
        'Margareth',
        'Hege',
        'Joe',
        'Gustav',
        'Birgit',
        'Mary',
        'Kai'
    ];
});
</script>

<p>The list will only consists of names matching the filter.</p>


</body>
</html>

the code is working fine when i use radio buttons.. this is the problem i'm facing




Tick checkbox after ticking another checkbox

enter image description here

I want the checkboxes to be clicked within the table after clicking the checkbox situated outside the table. As you can see, the PHP runs properly for select all, but if the student below select all is ticked, the checkboxes having student as their member doesn't get ticked. I need the same code working for all other checkboxes outside the table. The email ids are fetched through android studio.

 $("#selectall").change(function () {
$("input:checkbox").prop('checked', $(this).prop("checked"));
});
jQuery(function($) {
var $checks = $('input:checkbox').change(function() {
if (this.checked) {
  $checks.filter('[value="' + this.value + '"]').not(this).prop('checked', this.checked);
}
})
})




Checkbox RecycleView SQLQuery

In my Android Studio project i would start an SQLQuery Activity by checking a Checkbox: this should send a message to my database (1) when i check the CheckBox, and should send another (0) when CheckBox is not checked. I'm new in the Android World so I can'understand how to improve the CheckBox in my RecycleView. I'll show you my main and my SQL Activity, hope you can help me.

FrammentoUno.java (My main activity)

public class FrammentoUno extends AppCompatActivity {


private RecyclerView GetAllAllarmiListView;
/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See http://ift.tt/1Shh2Dk for more information.
 */
private GoogleApiClient mClient;
private Uri mUrl;
private String mTitle;
private String mDescription;

private Button frammentoUno, frammentoDue;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_one);

    addListenerOnButton();

    this.GetAllAllarmiListView = (RecyclerView) this.findViewById(R.id.GetAllAllarmiListView);

    new GetAllAllarmiTask().execute(new ApiConnector());

    mClient = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
    mUrl = Uri.parse("android-app://com.example.andrea/http/host_path");
    mTitle = "Standard Poodle";
    mDescription = "The Standard Poodle stands at least 18 inches at the withers";



    LayoutInflater factory = LayoutInflater.from(this);
    final View textEntryView = factory.inflate(R.layout.get_all_allarmi_list_view_cell, null);

    final CheckBox visto = (CheckBox) textEntryView.findViewById(R.id.visto);
    visto.setOnClickListener(btnListener);

    setListAdapter(new JSONArray());


}


private View.OnClickListener btnListener = new View.OnClickListener() {
    @Override
    public void onClick(View visto) {
        if (visto.isClickable()) {
            startActivity(new Intent(FrammentoUno.this, SQL_visto.class));
            Toast.makeText(FrammentoUno.this,
                    "Visto", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(FrammentoUno.this,
                    "Non Visto", Toast.LENGTH_LONG).show();

        }
    }
};

public void addListenerOnButton() {

    frammentoUno = (Button) findViewById(R.id.frammentoUno);
    frammentoDue = (Button) findViewById(R.id.frammentoDue);

    frammentoUno.setOnClickListener(new View.OnClickListener() {

        //Run when button is clicked
        @Override
        public void onClick(View v) {
            Intent i = new Intent(FrammentoUno.this, FrammentoUno.class);

            startActivity(i);
            Toast.makeText(FrammentoUno.this, "Allarmi Generali",
                    Toast.LENGTH_LONG).show();

        }
    });

    frammentoDue.setOnClickListener(new View.OnClickListener() {
        //Run when button is clicked
        @Override
        public void onClick(View v) {
            Intent i = new Intent(FrammentoUno.this, FrammentoDue.class);

            startActivity(i);
            Toast.makeText(FrammentoUno.this, "Controllo Ultimi Allarmi",
                    Toast.LENGTH_LONG).show();

        }
    });

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    switch (id) {
        case R.id.MENU_1:
        /*
            Codice di gestione della voce MENU_1
         */
            startActivity(new Intent(this, ControlloSbarre.class));
            return true;

        case R.id.MENU_2:
             /*
            Codice di gestione della voce MENU_2
         */
            startActivity(new Intent(this, LoginActivity.class));
            return true;
    }
    return false;
}


public void setListAdapter(JSONArray jsonArray) {
    RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
    this.GetAllAllarmiListView.setLayoutManager(layoutManager);
    this.GetAllAllarmiListView.setAdapter(new GetAllAllarmiListViewAdapter(jsonArray, this));
}



private class GetAllAllarmiTask extends AsyncTask<ApiConnector, Long, JSONArray> {
    @Override
    protected JSONArray doInBackground(ApiConnector... params) {
        return params[0].GetAllAllarmi();
    }

    @Override
    protected void onPostExecute(JSONArray jsonArray) {
        setListAdapter(jsonArray);
    }
}}

SQL_visto.java

public class SQL_visto extends FrammentoUno {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startService(new Intent(SQL_visto.this, BackgroundService.class));
}

public CheckBox visto;

public class SQLMain extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "web2park";

    static final String TABLE_NAME = "allarmi_ingressi";
    static final String COL_id_allarme = "id_allarme";
    static final String COL_id_park = "id_park";
    static final String COL_data_al = "data_al";
    static final String COL_stato = "stato";
    static final String COL_cod_allarme = "cod_allarme";
    static final String COL_descrizione = "descrizione";
    static final String COL_targa = "targa";
    static final String COL_visto = "visto";
    static final String COL_azione = "azione";
    static final String COL_varco = "varco";
    static final String COL_cassa = "cassa";

    private SQLiteDatabase database;

    public SQLMain (Context context) {
        super(context, DATABASE_NAME, null, 1);
        database = getWritableDatabase();
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE allarmi_ingressi (id_allarme INTEGER PRIMARY KEY, id_park TEXT, data_al TEXT, stato TEXT, cod_allarme TEXT, descrizione TEXT, targa Text, visto TEXT, azione TEXT, varco TEXT, cassa TEXT );");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

        android.util.Log.w(this.getClass().getName(),
                DATABASE_NAME + " database upgrade to version " + newVersion + " old data lost");
        db.execSQL("DROP TABLE IF EXISTS details");
        onCreate(db);
    }

    public final void addListenerOnVisto() {
        final CheckBox visto = new CheckBox(null);
        visto.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                if (((CheckBox) v).isChecked()) {
                    database.execSQL("UPDATE allarmi_ingressi SET visto = '1' WHERE visto = '0' ");
                    visto.setChecked(false);
                }}
        });
    }
}}

Other information: - I have an Adapter for my RecycleView, but i think CheckBox must be declared in main; - When I check CheckBox I get NullPointerException

Thanks for help.




android checkbox to string and verification

i have 12 check boxes in my layout. i need to make sure the user selects only 5, then press the save button. when he presses the save - the check boxes he selected should be shown in a text view and all other check boxes turn grey(unclickable). if he chooses more than 5 - toast tells him he must choose only 5. 1st problem i have is how to turn the other check boxes grey. 2nd problem is when he deselects 1 check box the size of my hashmap is still more than five.

here is code: public class MainActivity extends AppCompatActivity implements CompoundButton.OnCheckedChangeListener {

Map<String, String> states = new HashMap<String, String>();

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

    CheckBox checkboxMovies = (CheckBox) findViewById(R.id.chkInterestsMovies);
    checkboxMovies.setOnCheckedChangeListener(this);
    CheckBox checkboxAnimals = (CheckBox) findViewById(R.id.chkInterestsAnimals);
    checkboxAnimals.setOnCheckedChangeListener(this);
    CheckBox checkboxShopping = (CheckBox) findViewById(R.id.chkInterestsShopping);
    checkboxShopping.setOnCheckedChangeListener(this);
    CheckBox checkboxBooks = (CheckBox) findViewById(R.id.chkInterestsBooks);
    checkboxBooks.setOnCheckedChangeListener(this);
    CheckBox checkboxRestaurants = (CheckBox) findViewById(R.id.chkInterestsRestaurants);
    checkboxRestaurants.setOnCheckedChangeListener(this);
    CheckBox checkboxComputers = (CheckBox) findViewById(R.id.chkInterestsComputers);
    checkboxComputers.setOnCheckedChangeListener(this);
    CheckBox checkboxTV = (CheckBox) findViewById(R.id.chkInterestsTV);
    checkboxTV.setOnCheckedChangeListener(this);
    CheckBox checkboxPubs = (CheckBox) findViewById(R.id.chkInterestsPubs);
    checkboxPubs.setOnCheckedChangeListener(this);
    CheckBox checkboxDancing = (CheckBox) findViewById(R.id.chkInterestsDancing);
    checkboxDancing.setOnCheckedChangeListener(this);
    CheckBox checkboxMusic = (CheckBox) findViewById(R.id.chkInterestsMusic);
    checkboxMusic.setOnCheckedChangeListener(this);
    CheckBox checkboxCoffe = (CheckBox) findViewById(R.id.chkInterestsCoffe);
    checkboxCoffe.setOnCheckedChangeListener(this);
    CheckBox checkboxOther = (CheckBox) findViewById(R.id.chkInterestsOther);
    checkboxOther.setOnCheckedChangeListener(this);

}


@Override
public void onCheckedChanged(final CompoundButton buttonView, boolean isChecked) {
    if (isChecked) {
        states.put(String.valueOf(buttonView.getId()), buttonView.getText().toString());
    } else {
        states.remove(buttonView.getId());
    }
    Button btnSave = (Button) findViewById(R.id.btnSave);
    btnSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (states.size() == 5) {
                List<String> selectedStrings = new ArrayList<String>(states.values());
                TextView chkEditText = (TextView) findViewById(R.id.chkEditText);
                chkEditText.setText(selectedStrings.toString());
            } else {
                Toast.makeText(MainActivity.this, "Only 5 are allowed", Toast.LENGTH_SHORT).show();
            }
        }
    });

}

}

can anyone plz help me?