mercredi 31 mai 2017

Multiple update laravel with checkbox (LARAVEL 5.2)

I want to update the class data on the students I've selected. But I have constraints that the student data I have selected has not been successfully updated correctly. What is the error in writing my code?

The first I have a student table:

{!! Form::open(['method' => 'POST', 'action' => ['SiswaController@pindah_kelas']]) !!}
  <div class="panel panel-primary">
    <div class="panel-heading" align="center">Daftar Data Siswa</div>
    <table id="dataSiswa" class="table table-striped">
      <thead>
        <tr>
          <th><input type="checkbox" name"select-all" id="select-all" />
          <th>NIPD</th>
          <th>NISN</th>
          <th>Nama Siswa</th>
          <th>Kelas</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($data_kelas as $siswa): ?>
        <tr>
          <td><input type="checkbox" name="checkbox" id="checkbox" value=""></td>
          <td></td>
          <td></td>
          <td></td>
          <td></td>
          <td>
            <div class="box-button">
              
            </div>
            <div class="box-button">
              
            </div>
            <div class="box-button">
              {!! Form::open(['method' => 'DELETE', 'action' => ['SiswaController@destroy', $siswa->id]]) !!}
                <button type="submit" class="btn btn-danger btn-sm" title="Hapus"><i class="glyphicon glyphicon-trash"></i></button>
              {!! Form::close() !!}
            </div>
          </td>
        </tr>
        <?php endforeach ?>
      </tbody>
    </table>
  </div>
  {!! Form::submit('Pindah Kelas', ['class' => 'btn btn-primary form-control']) !!}
  {!! Form::close() !!}

This is my code javascript:

<script type="text/javascript">
  $(document).ready(function(){
    $('#select-all').click(function(){
      if(this.checked) {
        $(':checkbox').each(function(){
          this.checked = true;
        });
      }
      else {
        $(':checkbox').each(function(){
          this.checked = false;
        });
      }
    });
  });
</script>

And the second this is my Routes:

Route::get('siswa/pencarian_siswa', 'SiswaController@pencarian_siswa');
Route::resource('siswa', 'SiswaController');
Route::post('siswa', 'SiswaController@pindah_kelas');

The last i have controller:

public function pindah_kelas(Siswa $siswa, Request $request)
{
  $input = $request->id;
  $siswa->update($input)->whereIn('id', $input(['id_kelas' => 3]));
  Session::flash('flash_message', 'Data Siswa Berhasil Diupdate.');
  return redirect('kelas');
}

My question is how do I update the transfer of students from the current class into another class from the student data I have selected? I am very grateful if you can help me in solving this problem




Stop checkbox list from click

I had ng-repeat checkboxes on angularJS. I'm using library checkboxlist to implement multiple checkboxes with ng-repeat. I had a requirement that the users only can click the maximum number of checkboxes. I used $event.stopPropagation, and it works, but the ng-model is not updated because I have no idea how to access checkboxlist.

Controller

$scope.mealCBChanged = function($event, mc){
    if(mc.selectedCBId.length > 2){
        $event.preventDefault();
        alert("You can't select more than " + 2);
    }
}

HTML

<div ng-repeat="m in mc.meals">
  <input type="checkbox" name="" 
         id="" 
         checklist-model="mc.selectedCBId" 
         ng-init="mc.selectedCBId = []" 
         ng-click="mealCBChanged($event, mc)" 
         checklist-value="m.name"/>
  <label for=""><span class="checkbox primary primary"><span></span></span></label>
</div>

Problem

When I select the third checkbox, the alert invoked and the third checkbox doesn't click because $event.preventDefault() is working fine. But the mc.selectedCBId has 3 items in the array, it supposedly has two items.




select checkbox by name and check if it checked javascript

I am trying to test if checkbox is checked. I have more inputs and they have different names. I managed to select the input but I can't seem to check if it wa selected. If I add to the condition '= true' it is checked once I load the page. If I leave it just .checked it doesn't do anything

  1. Have I selected the input right? Please note I want to select it by name rather than id or class

  2. Why is it that once the page loads my condition for if statement doesn't work?


<input type="checkbox" name="name1">
<input type="checkbox" name="name2">
<input type="checkbox" name="name3">
<input type="checkbox" name="name4">


const firstInput = document.getElementsByName('1');
if (firstInput[0].checked) {
    console.log('checked');
}




processing dynamic input fileds using angularjs and php

I am generating dynamic input fields using angularjs ng-repeat inside a table where each row contains a text field and checkbox.I want to save the values of these dynamic text filed and checkbox using a single save button.Text fields may have null values or any other values and checkbox may be all checked,all unchecked and few checked and few unchecked. If the check box is checked then i want to save "checked":"yes" otherwise as no.I have also a single date input field to save the record for this particular date.Now i want to form an array from the dynamic inputs in angular js then pass it to a php page and process there.My expected array format is :

[{"Did":"10","dname":"sales","date":"2017-06-01",
"info":
{"eid":"10","name":"nam1","checked":"yes","cmnt":"on time"},
{"eid":"20","name":"nam2","checked":"NO", "cmnt":"absent"},
{"eid":"30","name":"nam3","checked":"yes","cmnt":""},
{"eid":"40","name":"nam4","checked":"NO","cmnt":"OK"},
{"eid":"50","name":"nam5","checked":"YES","cmnt":""},
{"eid":"60","name":"nam6","checked":"YES","cmnt":""},
{"eid":"70","name":"nam7","checked":"YES","cmnt":""},
{"eid":"80","name":"nam8","checked":"NO","cmnt":"Late"},
{"eid":"90","name":"nam9","checked":"YES","cmnt":""}
        }];

var myApp = angular.module('myApp',['ui.bootstrap']);

myApp.controller('MyCtrl', function($scope) {
    $scope.list = [
    {"dept_id":"d10","dname":"sales","supervisor":"ms1001"},
    {"eid":"10","ename":"nam1"},

    {"eid":"20","ename":"nam2"},

    {"eid":"30","ename":"nam3"},

    {"eid":"40","ename":"nam4"},
    {"eid":"50","ename":"nam5"},

    {"eid":"60","ename":"nam6"},

    {"eid":"70","ename":"nam7"},
    {"eid":"80","ename":"nam8"},

    {"eid":"90","ename":"nam9"},

    {"eid":"120","ename":"nam10"}


    ];

        $scope.did= $scope.list[0].dept_id;
         
        $scope.dname= $scope.list[0].dname;
        $scope.sp_name= $scope.list[0].supervisor;
        


    $scope.selectedText = 'Select All';
        $scope.isAll = false;                           
        $scope.selectAll = function() {
        
            if($scope.isAll === false) {
                angular.forEach($scope.list, function(data){
                data.checked = true;
                });
        $scope.isAll = true;    
        $scope.selectedText = 'Deselect All';
        } else {
        angular.forEach($scope.list, function(data){
                data.checked = false;
                });
        $scope.isAll = false;   
        $scope.selectedText = 'Select All';
        }
        };
      
        $scope.selectedFriends = function () {
        return $filter('filter')($scope.list, {checked: true });
   
      };
  
//date picker
  
  $scope.open = function($event) {
    $event.preventDefault();
    $event.stopPropagation();

    $scope.opened = true;
  };

  $scope.dateOptions = {
    formatYear: 'yy',
    startingDay: 1
  };

 
  $scope.format = 'dd-MMMM-yyyy';


//end of date picker




    
});
<html>
<head>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link href="http://ift.tt/2pj6mAc" rel="stylesheet">

<script src="http://ift.tt/20g0BuL"></script>

<script src="http://ift.tt/2jSmNwf"></script>  

    <script src="http://ift.tt/2qGIbrj"></script>
    <script src="http://ift.tt/2rbKFB9"></script>

<script src="http://ift.tt/2qGN7Mt"></script>
<link rel="stylesheet" href="http://ift.tt/1RrshYi">

  
<style>
  .full button span {
    background-color: limegreen;
    border-radius: 32px;
    color: black;
  }
  .partially button span {
    background-color: orange;
    border-radius: 32px;
    color: black;
  }
</style>

</head>

<div class="container">

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

   <div class="row">
       <div class="col-sm-3" style="background-color:yellow;">
         <p>Department ID::</p>
        </div>

       <div class="col-sm-3" style="background-color:skyblue;">
        <p>Dept  Name:</p>
        </div>

        <div class="col-sm-3" style="background-color:pink;">
         <p>Supervisor name name:</p>
         </div>

                <div class="col-sm-3">
        <p class="input-group">
          <input type="text" " class="form-control" uib-datepicker-popup="" 
          ng-model="dt" is-open="opened" min-date="minDate" max-date="'2018-06-22'"
          ng-model-options="{timezone: 'UTC'}" 
          datepicker-options="dateOptions" date-disabled="disabled(date, mode)"
          ng-required="true" close-text="Close" />
          <span class="input-group-btn"> 
                <button type="button" class="btn btn-default" ng-click="open($event)">
                <i class="glyphicon glyphicon-calendar"></i></button>
              </span>
        </p>
       </div>



  </div>



<table  class="table table-striped table-bordered">
    <thead>
      <tr>
         <th>Employee ID</th>
        <th>name</th>
        <th><label>Attendence</label><br><span id="selectall" ng-click="selectAll()"><input 
    type="checkbox"></span></th>
<th>comment</th>        

</tr>  
 </thead>
    <tbody>
  
   <tr ng-repeat="data in list" ng-if="$index">
      <td>  </td>
      <td>  </td>

<td> <input type="checkbox"  value=""  ng-checked="data.checked" ng-model="data.checked"></td>
<td>
<input type="text" ng-model="data.cmnt" ></td>
 </tr>
</tbody>
  
</table>

</div>

<button type="button" ng-click="saveAll()">Save all</button>
</div>
</html>



Binding Checkbox object from View to Controller

I'm new at Spring Boot and I face huge difficulties for binding object from a view with ThymeLeaf to a List in my Controller. I explain : I got a Form for create events, in this Form there are checkboxes generated dynamically with a List of "Enfant" (listEnfant) stored in the database :

GET REQUEST @Controller public class EventController {

@RequestMapping(value="/createEvent",method=RequestMethod.GET)
public String Affichercreationcotisation(Model model,Enfant enfant){

    List<Enfant> listEnfant = gardeMetier.findEnfantfamille();
    model.addAttribute("listEnfant", listEnfant);

    List<String> ListEnfants = new ArrayList<>(0);
    model.addAttribute("listEnfantsChoisis", ListEnfants);

    return "eventForm";
}

When I run the Application there is no problem with the GET Request I got the checkboxes which are expected

As you can see i created an empty List which I could use to store selected checkboxes objects

HTML

    <th:block th:each="e :${listEnfant}">                       
    <input type="checkbox" th:field="" />   
    <label th:text="${e.name}"></label>
    </th:block>

I don't know and don't find (or understand) what to do with my post request and how to configure the th:field to put the selected checkboxes objects in a List when the Form is submitted

@RequestMapping(value="/saveEvent",method=RequestMethod.POST)
    public String saveEvent()   {
}

I hope someone will help me because I'm looking for the solution for hours now :(




How to determine if checkbox checked in PDF that is not a form

We receive PDF files from many sources and have to read/parse the data in them.

In some cases the checkboxes are checked or unchecked and we get those values as Unicode that we can look for and determine if it is checked or not.

However, in some cases that approach doesn't work.

We know the pdf does not have a form of any type, not XFA nor Acroform, so we can only parse from String values.

However, in the pdfs that don't use Unicode to represent checkboxes I am not sure how else I could figure out if it is filled/checked or not.

I am pasting the list of Unicode I look for for the PDFs that do have Unicode for it, and that works great for those files. It is the ones that don't have Unicode for it that I am having issues with.

I have attached an image of one checkbox checked and unchecked that is not using Unicode.

Part of the PDF document

Thanks

We are using currently using PDFBox.




Perform Action Based on Checking Box in Adobe using Javascript

I'm attempting to change a textbox value whenever a user checks a checkbox in Adobe Acrobat Pro XI using Java, and am inexperienced in Java. I am getting an error of Syntax Error: Illegal Character 7: at line 9 based on the below code:

//Checked
if (this.getField("myCheckBox").value != "Off") { 
this.getField("myTextBox").value = util.printd("mm/dd/yyyy HH:MM:ss", new  Date());

//Not Checked
} else { 
this.getField("myTextBox ").value = “”;
}

I have the feeling I need to change the brackets somehow, can anyone clarify?

Thanks for any help!




Make/ Create checkbox component in react native

I have been facing some issues with the native base checkbox and AsynStorage. In fact, AsynStorage only accepts strings by default BUT can store boolean variables also, I tried to use that method but I get a string stored every time. While the checkbox does only accept boolean variables and throws a warning if I tried to use a string and it does not show the previous state of the checkbox (checked or not ). So, I decided to make my own checkbox using TouchbleOpacity .. So do you guys have any idea how to make it ? Here is the result i want to achieve: enter image description here




unchecking a checkbox from a button Angular2

I am developing a project using Angular2. I have a list called brands which contain other list called descriptions.

this list will create checkboxes:

<div *ngFor="let brand of brands">
    
    <div*ngFor="let description of brand.descriptions" >
        <input type="checkbox" name="checkbox" />
    </div>
</div>

and I have two text boxes:

<input name="brand" />
<input name="description" />
<button>uncheck</button>

the button event will uncheck only the checkbox with the brand and the description that mentioned in the input without changing or rebuilding the list because I need to keep checkboxes' status correct.

any idea?




How do I save multiple checkbox values in a single column in the database and retrieve it using laravel

I have 15 Checkbox at my admin panel so only website admin can select or cancel them.

I need to save checkbox's that checked at my table like this:

Name: car,food,game,...

HTML:


    <div class="form-group">
        <label for="art" class="checkbox-inline">
            Art
         </label>
         <label for="artitecture" class="checkbox-inline">        
              Artitecture
         </label>
          <label for="business" class="checkbox-inline">
              Business
          </label>
              ...
          <div class="form-group">
               
          </div>
 

My Controller Store Function :

 public function store(Request $request)
 {
    $add_hobby=new Hobbies;
    $add_hobby->name=$request->all();
    $add_hobby->save();
    return redirect()->back();
 }

Also try this but only save the last one :

public function store(Request $request)
 {
    $add_hobby=new Hobbies;
    $add_hobby->name=$request->input('car');
    $add_hobby->name=$request->input('food');
      ...
   $add_hobby->name=$request->input('fashion');
    $add_hobby->save();
    return redirect()->back();
 }

I tried this too but I got Error :

 public function store(Request $request)
{
    $request->merge([
    'name' => implode(',', (array) $request->input('game')),
    'name' => implode(',', (array) $request->input('food')),
      ...
      'name' => implode(',', (array) $request->input('fashion')),
]);

    $add_hobby=new Hobbies;
    $add_hobby->name=$request->input()->all();
    $add_hobby->save();
    return redirect()->back();
}

Anyone can help?

Of course is not necessary save at one column but also i don't know another way to save them




Auto check checkboxes by retriving their values

I've met some issues by retrieving checkboxes from an array of values.

I tried to auto check the checkboxes which are concerned by an array.

array[i] generate some input of checkboxes target[i] is an array which contains some checkboxe's values. So when I refresh the page, I have to see that "tuesday" and "Wendesday" is already selected. cf.the snippet (I don't know if I explain correctly)

// table which generate checkboxes
                        var array = new Array();
                        array[0]="Monday";
                        array[1]="Tuesday";
                        array[2]="Wendesday";
                        array[3]="Thirsday";
                        array[4]="Friday";
                        array[5]="Saturday";
                        array[6]="Sunday";

                // values to of checkboxes I want to auto-check
                        var target = new Array();
                        target[0]="Tuesday";
                        target[1]="Wendesday";


                        var cbh = document.getElementById('checkboxes');
                    var val = '';
                    var cap = "";

                    var j = "";
                        for (var i in array) {
                                //Name of checkboxes are their number so I convert the i into a string. 
                                j = i.toString();
        
                                val = j;
                                //cap will be the value/text of array[i]
                                var cb = document.createElement('input');
                                var label= document.createElement("label");
        
                          cap = array[i];
                          var text = document.createTextNode(cap);
                          cb.type = 'checkbox';
                          cbh.appendChild(cb);
                          cb.name = cap;
                          cb.value = val;
                          label.appendChild(cb); 
                          label.appendChild(text);
                          cbh.appendChild(label);
                        }
      
* {
                        box-sizing: border-box;
                        }
                        #data {
                            padding:5px;
                                width:100vw;
                        }
                        .multiselect {
                                overflow: visible;
                                padding:0;
                                padding-left:1px;
                                border:none;
                                background-color:#eee;
                                width:100vw;
                                white-space: normal;
                                height:50px;
                        }
                        .checkboxes {
                                height:100px;
                                width:100px;
                                border:1px solid #000;
                                background-color:white;
                                margin-left:-1px;
                                display:inline-block;
                        }
      
            label {
                                display: inline-block;
                                border: 1px grey solid;
                                padding:5px;
                        }
<form>
                        <div id="data">
                                <div class="multiselect">
                                        <div id="c_b">
                                                <div id="checkboxes">
                                                </div>
                                        </div>
                                </div>
                        </div>
                </form>
    Tuesday and Wendesday have to be automitacly checked

Thank you for your help. Regards




disabled="disabled" on input type checkbox doesn't work

I have the following code:

<div class="row" style="margin-top:1%;">
 <div class="col-md-12">
  <ul class="List">
    @foreach (var req in requests)
    {
     <li>
      <div>
        @if(req.Equals("Test"))
        {
         <label><input type="checkbox" onclick="setRequestor(this)" />@req</label>  
        }
        else
        {
         <label><input type="checkbox" disabled="disabled" />@req</label>   
        }
      </div>
     </li>
    }
  </ul>
 </div>
</div>

The Problem is that disabled="disabled" is always ignored. If I inspect the Code with Developer Tools I don't see the disabled attribute. I see only:

<input type="checkbox" /> 




AEM/CQ: Checkbox is checked saves a Boolean value of TRUE,How to save a Boolean value as FALSE if we Unchecked?

For Example,I have created a check box with below properties

<checkbox1
                    jcr:primaryType="cq:Widget"
                    checked="false"
                    defaultValue="false"
                    fieldLabel="Sample"
                    inputValue="true"
                    name="./sample"
                    checkboxBoolTypeHint="{Boolean}true"
                    type="checkbox"
                    xtype="selection">
                    <listeners
                        jcr:primaryType="nt:unstructured"
                        check="function(isChecked){var panel = this.findParentByType('panel'); var fields = panel.find('name', './sample'); for (var i=0;i&lt;fields.length; i++) {if (fields[i].xtype == 'hidden') { if (isChecked.checked) {fields[i].setDisabled(true);} else {fields[i].setDisabled(false);}}}}"/>

</checkbox1>
<hiddenCheckbox1
                    jcr:primaryType="cq:Widget"
                    disabled="{Boolean}true"
                    ignoreData="{Boolean}true"
                    name="./sample"
                    value="{Boolean}false"
                    xtype="hidden"/>

If we checked/enabled the check box it is showing the property "Sample" like below sample Boolean true (working fine) If we Unchecked/disable the checkbox then it is not showing the property "Sample"

Expectation: I want to show Sample Boolean false if we Unchecked/disable the checkbox




How to use checkbox to run different Cesium Model?

My goal is runing the cesium models with checkbox. Like, there are 3D Models Coloring, GeoJSON and TopoJSON, Polyline...etc. and there are some checkbox to relate the models. If I check 3D models coloring checkbox, this model shows on the globe, if I uncheck, there is no more model. If I check two checkbox, It will show two models on the globe. Some thing like that.

Thanks!




Bootstrap btn-group inside form-group and border-radius

I try to remove border-radius of first child label with no success. For example, I tried with no success:

.btn-group .label:first-child {
    border-top-left-radius:0px;
}

The labels are inside btn-group which are inside form-group:

http://ift.tt/2rodKKt

enter image description here

How to remove first label border-radius top left and bottom left?




Request for CheckBox multiple choice

I had a choice list I changed it by a checkbox for multiple choice. This following my old request MySQL:

 $this->_sqlWhere.="`piecearticles`.`ID_Article`=`article`.`ID_Article` 
 AND `article`.`ID_LRU`=`lru`.`ID_LRU` AND `lru`.`LRU`='" . $this->_lru . "'";

Since I changed to a multiple choice,should I change it or this one it's fine ? Thank you.




WPF/VB How to set a threestate checkbox (or nullable boolean) to Nothing(null)

The title explain all itself. For VB the keyword Nothing is the same as False.

This code verify if checkbox is a three state checkbox, and set the default value, indeterminate if is a "three state", and false if is not.

myThreeStateChkbox.IsChecked = If(myThreeStateChkbox.IsThreeState, Nothing, False)

The result is the same, always False. How can I set the indeterminate state ?




Checkboxes in recyclerview get unchecked when recyclerview scroll up and down

I have Recyclerview with name, contact and checkbox items. when i select checkbox it get select, when i scroll up or down the recylerview then that time checked checkbox got unselected. what Should i do? Thanks in advance !!! Please see pic.Recyclerview items




Auto check Checkbox on comparing the values from json

json data from server

I want to check the roll and roll check days if they are equal then auto check that check box and can also un-check that if need by user.

1.)Check if roll and rollcheck data from Json are equal then check the check box automatically.

2.)If needed by user ..user can also uncheck that automatically checked checkbox

MainActivity.java

public class MainActivity extends AppCompatActivity {

    Toolbar toolbar;
    FloatingActionButton fab;
    ListView list;
    TextView txt_menu;
    String dipilih;
    private static final String TAG = MainActivity.class.getSimpleName();

    Adapter adapter;
    ProgressDialog pDialog;

    List<Data> itemList = new ArrayList<Data>();


    private static String url = "http://url.php";

    public static final String TAG_NAMA = "nama";
     public static final String TAG_ROLL = "roll";
    public static final String TAG_ROLLCheck = "rollcheck";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        fab     = (FloatingActionButton) findViewById(R.id.fab);
        list    = (ListView) findViewById(R.id.list_menu);

        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String checkbox = "";
                for (Data hold : adapter.getAllData()) {
                    if (hold.isCheckbox()) {
                        checkbox += "\n" + hold.getMenu();
                    }
                }
                if (!checkbox.isEmpty()) {
                    dipilih = checkbox;
                } else {
                    dipilih = "Anda Belum Memilih Menu.";
                }

                formSubmit(dipilih);
            }
        });

        callVolley();

        adapter = new Adapter(this, (ArrayList<Data>) itemList);
        list.setAdapter(adapter);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
                adapter.setCheckBox(position);
            }
        });

    }

    private void formSubmit(String hasil){
        AlertDialog.Builder dialog = new AlertDialog.Builder(this);
        LayoutInflater inflater = getLayoutInflater();
        View dialogView = inflater.inflate(R.layout.form_submit, null);
        dialog.setView(dialogView);
        dialog.setIcon(R.mipmap.ic_launcher);
        dialog.setTitle("title");
        dialog.setCancelable(true);

        txt_menu = (TextView) dialogView.findViewById(R.id.txt_menu);

        txt_menu.setText(hasil);

        dialog.setNeutralButton("CLOSE", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

        dialog.show();
    }

    private void callVolley(){
        itemList.clear();
        // menapilkan dialog loading
        pDialog = new ProgressDialog(this);
        pDialog.setMessage("Loading...");
        showDialog();

        // membuat request JSON
        JsonArrayRequest jArr = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {
                        Log.d(TAG, response.toString());
                        hideDialog();

                        // Parsing json
                        for (int i = 0; i < response.length(); i++) {
                            try {
                                JSONObject obj = response.getJSONObject(i);

                                Data item = new Data();

                                item.setMenu(obj.getString(TAG_NAMA));

                                 item.setRoll(obj.getString(TAG_ROLL));
                                item.setRollCheck(obj.getString(TAG_ROLLCheck));

                                // menambah item ke array
                                itemList.add(item);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }

                        // notifikasi adanya perubahan data pada adapter
                        adapter.notifyDataSetChanged();
                    }
                }, new Response.ErrorListener() {

            @Override
            public void onErrorResponse(VolleyError error) {
                VolleyLog.d(TAG, "Error: " + error.getMessage());
                hideDialog();
            }
        });

        // menambah request ke request queue
        AppController.getInstance().addToRequestQueue(jArr);
    }

    private void showDialog() {
        if (!pDialog.isShowing())
            pDialog.show();
    }

    private void hideDialog() {
        if (pDialog.isShowing())
            pDialog.dismiss();
    }

}

Adapter.java

public class Adapter extends BaseAdapter {

    private Context activity;
    private ArrayList<Data> data;
    private static LayoutInflater inflater = null;
    private View vi;
    private ViewHolder viewHolder;

    public Adapter(Context context, ArrayList<Data> items) {
        this.activity = context;
        this.data = items;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

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

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

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

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        vi = view;
        final int pos = position;
        Data items = data.get(pos);

        if(view == null) {
            vi = inflater.inflate(R.layout.list_row, null);
            viewHolder = new ViewHolder();
            viewHolder.checkBox = (CheckBox) vi.findViewById(R.id.cb);
            viewHolder.menu = (TextView) vi.findViewById(R.id.nama_menu);
            viewHolder.roll = (TextView) vi.findViewById(R.id.roll);
            vi.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) view.getTag();
            viewHolder.menu.setText(items.getMenu());
            viewHolder.roll.setText(items.getRoll());
        }

        if(items.isCheckbox()){
            viewHolder.checkBox.setChecked(true);
        } else {
            viewHolder.checkBox.setChecked(false);
        }

        return vi;
    }

    public ArrayList<Data> getAllData(){
        return data;
    }

    public void setCheckBox(int position){
        Data items = data.get(position);
        items.setCheckbox(!items.isCheckbox());
        notifyDataSetChanged();
    }

    public class ViewHolder{
        TextView roll;
        TextView menu;
        CheckBox checkBox;
    }
}

Data.java

public class Data {
    private String roll;
    private String menu;
    private boolean check;
    private String roll_check;
    public Data() {}

    public Data(String roll,String menu, boolean check,String roll_check) {
        this.roll=roll;
        this.menu = menu;
        this.check = check;
        this.roll_check = roll_check;
    }

    public String getRoll() {
        return roll;
    }

    public void setRoll(String roll) {
        this.roll = roll;
    }

    public String getRollCheck() {
        return roll_check;
    }

    public void setRollCheck(String roll_check) {
        this.roll_check = roll_check;
    }






    public String getMenu() {
        return menu;
    }

    public void setMenu(String menu) {
        this.menu = menu;
    }

    public boolean isCheckbox() {
        return check;
    }

    public void setCheckbox(boolean check) {
        this.check = check;
    }
}




Why checkbox style is not bootstrap style

Hi I'm using bootstrap in my Angular application and all other styles are working like they should, but checkbox style doesn't. It just look like plain old checkbox. Here is my html

    <div class="container">

    <form class="form-signin">
        <h2 class="form-signin-heading">Please log in</h2>
        <label for="inputEmail" class="sr-only">User name</label>
        <input [(ngModel)]="loginUser.Username" type="username" name="username" id="inputEmail" class="form-control" placeholder="User name" required autofocus>
        <label for="inputPassword" class="sr-only">Password</label>
        <input [(ngModel)]="loginUser.Password" type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>

        <a *ngIf="register == false" (click)="registerState()">Register</a>
        <div class="checkbox">
            <label>
                <input type="checkbox" [(ngModel)]="rememberMe" name="rememberme"> Remember me
            </label>
        </div>
        <button *ngIf="register == false" (click)="login()" class="btn btn-lg btn-primary btn-block" type="submit">Log in</button>
    </form>

</div>

Here is my github repo and one example http://ift.tt/2qzSuOB

here is what it looks like

checkbox style without bootstrap

Here is what I wan't it o look like with bootstrap style

bootstrap styled checkbox




Unable to get second Checkbox onwards status in gridview in asp.net c#

I am adding Select Checkbox at every row in GridView while loading from database. Below is my aspx page code:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                Width="100%" onrowcancelingedit="GridView1_RowCancelingEdit" 
                    onrowdatabound="GridView1_RowDataBound" onrowediting="GridView1_RowEditing" 
                    onrowupdating="GridView1_RowUpdating">
                <Columns>
                    <asp:TemplateField HeaderText="Select">
                        <ItemTemplate>
                            <asp:CheckBox ID="cbSelect" runat="server"></asp:CheckBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="ID">
                        <ItemTemplate>
                            <asp:Label ID="lblid" runat="server" Text='<%# Eval("ID") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Part Number">
                        <ItemTemplate>
                            <asp:Label ID="lblpn" runat="server" Text='<%# Eval("PartNumber") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Part Desc">
                        <ItemTemplate>
                            <asp:Label ID="lblpd" runat="server" Text='<%# Eval("PartDesc") %>'>
                            </asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

I want to read the data from the rows which are selected in the respective Checkbox. For this I have done following code in Button Click:

 for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    GridViewRow dr = GridView1.Rows[i];

                    Label lblID = (Label)dr.FindControl("lblid");
                    ID = Convert.ToInt32(lblID.Text);

                    CheckBox checkBox = (CheckBox)dr.FindControl("cbSelect");
                    if (checkBox.Checked)
                    {
}
}

Now if I select single row in grid then I am able to get the checkbox status Checked for that particular row.

But If I select multiple rows then I am getting only first selected row's checkbox status as checked. From second row I am getting Check status as Unchecked. But I am able to get correct value in lblID label control.

Following is my function to fill gridview:

 public void showgrid(string Location)
    {
        DataTable dt = new DataTable();

        con.Open();
        string strQuery = "";
        SqlDataAdapter sda = new SqlDataAdapter();
        if (chkConsiderPart.Checked)
            strQuery = "select * from InventoryDetails where Status='Stocked' and ToLocation='" + Location + "' and PartNumber='" + ddlPartNumber.SelectedItem.Text + "'";
        else
            strQuery = "select * from InventoryDetails where Status='Stocked' and ToLocation='" + Location + "'";
        SqlCommand cmd = new SqlCommand(strQuery);
        cmd.CommandType = CommandType.Text;
        cmd.Connection = con;
        sda.SelectCommand = cmd;
        sda.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();

        if (dt.Rows.Count == 0)
        {
            lblRowsStatus.Text = "No Records found for the selection.";
        }
        else
        {
            lblRowsStatus.Text = "There are " + dt.Rows.Count.ToString() + " Records found for the selection.";
        }
    }

I am only calling it in:

 if (!IsPostBack)
        {  
 showgrid(ddlFromLocation.SelectedItem.Text);
        }

Also there was post-back at certain events of other controls. but even if I removed them same issue is happening.

Note: There is no code written in any of Gridview Events.




Checkbox not functioning

I'm new to PHP and I hope someone can help me. I have 4 PHP files and they are basically a form for the user to fill, then the system will navigate it to validate page, and user will click submit to save it. I have a problem in the checkbox part.

The error shows :

Notice: Array to string conversion in C:\xampp\htdocs\LM\LMvalidate_reservation.php

I have simplified the code to show only the checkbox part for easier understanding. I hope someone(s) can help me in this.

LMreservation.php

<form action="LMvalidate_reservation.php" method="post">
  
          <div class="col-md-4"><b>Please check (√ ) the module(s) that you want to attend:</b><br></div>
        <div class="col-md-8">
        <input type="checkbox" class="get_value" value="WEBOPAC Usage">WEBOPAC Usage<br>
                <input type="checkbox" class="get_value" value="Accessing Online Database Skill">Accessing Online Database Skill<br>
                <input type="checkbox" class="get_value" value="E-Books and E-Journals Accession">E-Books and E-Journals Accession<br>
                <input type="checkbox" class="get_value" value="Digital Collection Accession">Digital Collection Accession<br>
                <input type="checkbox" class="get_value" value="EQPS Exam Papers">EQPS Exam Papers<br>
                <input type="checkbox" class="get_value" value="Information Searching Strategy">Information Searching Strategy<br>
                <input type="checkbox" class="get_value" value="SCOPUS & Web Of Science Usage Skill">SCOPUS & Web Of Science Usage Skill<br>
                <input type="checkbox" class="get_value" value="Reference Management Software (EndNote & Mendeley)">Reference Management Software (EndNote & Mendeley)<br>
                <input type="checkbox" class="get_value" value="UiTM Institutional Repository (Thesis & Dissertation)">UiTM Institutional Repository (Thesis & Dissertation)<br>
                <input type="checkbox" class="get_value" value="Digital Map">Digital Map<br>
                <input type="checkbox" class="get_value" value="E-Newspaper (BLIS (Bernama Library & Infolink Service)">E-Newspaper (BLIS (Bernama Library & Infolink Service))<br>
                <input type="checkbox" class="get_value" value="Facility">Facility<br><br>
                </div>
          


          <script>
                        $(document).ready(function(){
                        $('#submit').click(function(){
                        var insert = [];
                        $('.get_value').each(function(){
                        if($(this).is(":checked"))
                        {
                        insert.push($(this).val());
                        }
                        });
                        insert = insert.toString();
                        $.ajax({
                        url: "insert.php",
                        method: "POST",
                        data:{insert:insert},
                        success:function(data){
                        $('#result').html(data);
                        }
                        });
                        });
                        });
                   </script>
                   

<input type="submit" name="LMreservation_form" value="Submit"> 


</form>

LMvalidate_reservation.php

<?php
 
if (isset($_POST['LMreservation_form'])) {
 
  $module = "";
  $count_error = 0;
  $msg = "";
 
  // validate if submitted variables empty show error msg else put in local variables
 
  }
  if (isset($_POST['module']) && ($_POST['module'] != ""))
    $module = $_POST['module'];
  else
  {
    $msg .= "Error: Please select your module.<br>";
    $count_error++;
  }
  
  if ($count_error > 0) {
        echo $msg;
    echo "$count_error error(s) detected.";
    die();
    // display error(s) here and stop
  }
}
else {
  echo "Error: You have execute a wrong PHP. Please contact the web administrator.";
  die();
}
 
?>

<!DOCTYPE html>
<html>
<head>
  
</head>

<body>

<form action="LMsave_reservation.php" method="post">
<table> 
         <tr>
      <td class="col-md-4 col-xs-4">Module:</td>
      <td class="col-md-8 col-xs-8"><?php print $module; ?><input type="hidden" name="module" value="<?php echo $module; ?>"></td>
    </tr>

   
  </table><br>

  <input type="submit" name="LMreservation_validate" value="Save My Reservation">


</form>

</body>
</html>

LMsave_reservation.php

<?php
 
if (isset($_POST['LMreservation_validate'])) {
 
  // Connection variables
  $servername = "localhost";
  $username = "root";
  $password = "";
  $dbname = "lm_reservation";
 
  try {
      $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
      $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
       
      // Prepare the SQL statement
          $stmt = $conn->prepare("INSERT INTO lmreservation(name, studentstaffid, faculty, contactno, email, program, participant, attandance, module, date, starttime, endtime) VALUES (:name, :studentstaffid, :faculty, :contactno, :email, :program, :participant, :attandance, :module, :date, :starttime, :endtime)");
       
      // Bind the parameters

          $stmt->bindParam(':module', $module, PDO::PARAM_STR);

       
      // insert a row

          $module = $_POST['module'];
          
      $stmt->execute();
     
      echo "Your application is successful. Have a nice day! :)";
      }
 
    catch(PDOException $e)
    {
        echo "Error: " . $e->getMessage();
    }
 
    $conn = null;
  }
 
 ?>

insert.php

<?php
if(isset($_POST["insert"]))
{
 $conn = mysqli_connect("localhost", "root", "", "lm_reservation");
 $query = "INSERT INTO lmreservation(modules) VALUES ('".$_POST["insert"]."')";
 $result = mysqli_query($conn, $query);
}
?>



mardi 30 mai 2017

Angular2 - Material2 - Custom Checkbox

I'm working on creating a custom checkbox based on the angular material2 project. Everything seems to be working at first but when I update model values in code, the checkbox does not un-check even though angular registers the change. See the plunker for a demo.

The relevant code to update the model values is:

private _parentValue:bool = false;
get parentValue()
{
    return this._parentValue;
}
set parentValue(val)
{
    this._parentValue = coerceBooleanProperty(val);

    this.value1 = this._parentValue;
    this.value2 = this._parentValue;
    this.value3 = this._parentValue;
}

I apologize in advance if I have done something incorrect here as this is my first time posting to stack overflow.




Checkmarks don't show in checkbox on Window.print Angularjs

I am using AngularJs to display a few checkboxes. I have a click event which writes the current html to a window using document.write. However, when the new window opens for printing, none of the checkboxes are checked.

Here is the function which prints the document to the window:

  $scope.printForm = function () {
var doc = document.getElementById('myForm').outerHTML;

var myWindow = $window.open('', '', 'width=1100, height=1000');
myWindow.document.write(doc);
myWindow.print();

};

Here is the HTML for the checkboxes:

`<div ng-repeat="c in f.Choices" >
<input type="checkbox" ng-disabled="true" ng-model="c.isSelected" />&nbsp;&nbsp; </div>`

Here is what it looks like BEFORE I click "printForm"enter image description here

And here is what i looks like after I click "printForm":enter image description here

Any assistance is greatly appreciated.




Checkbox data with MongoDB

The following code allows user's to check a box to include an amenity on a post using MongodB/Node/Express. It is working perfectly to let users select their amenities and then shows those selections as icons.

However I am unable to EDIT these posts in my edit route . That is the problem. See code at bottom. How would I change my code to be able to edit the icons?

// Simplified Schema

   var rentalsSchema = new mongoose.Schema({
       amenities: Array
    });

// User Checks their amenities

<input type="checkbox" name="amenities" value="wifi"><span>Wi-fi</span>
<input type="checkbox" name="amenities" value="tv"><span>TV</span>

// This code loops through the array and shows the relevant icons using Google's material icons.

  <div class="list-group">
       <li class="list-group-item active">Amenities</li>
       <li id="amenitiesBox" class="list-group-item">
        <% for(var i=0; i<rentals.amenities.length; i++){ %>
        <i class="material-icons"><%=rentals.amenities[i]%></i>
        <% } %>
      </li>
      </li>
      </div>
      </div>

// The problem is here in my edit route. Simplified below

        <form id='rentalEdit' action="/rentals/<%=rentals._id %>/?_method=PUT" method ="POST"> 

 <input Checked type="checkbox" name="rentals[amenities]" value="wifi"><span>Wifi</span> 

        </form>




How to create JCheckBox for elements of an HashMap

I have an HashMap that fills in by a function in this mode:

private static Map<String, String> film = new HashMap<>();

   public static void init() {
   film.put(getIDFilm(), getTitle());
  }

Then each element of this Map will be a CheckBox. For example if the Map has 6 elements, it must create 6 checkboxes and it's important that I have the access to each single checkbox later, so I can specify for example:

if checkbox2 is selected, do this.

So is there any way to make these checkboxes dynamically according to the HashMap's size?




dynamic checkbox with icheck style

I'm using icheck for some cool checkboxes but there's a problem.

When I load the page, the initial checkboxes have the correct style, but when I append checkboxes with jquery, the new checkboxes aren't displaying themselves.

here's some code :



this is the checkboxes that are loaded with HTML / TWIG when the page is opened, they are displayed

then :

text_checkbx = '<label class="ckbox">Valider<input type="checkbox" name="validate"></label>'

this is the exact same code than the HTML for the append in JQUERY

text = text + text_checkbx + '</div>';
$('.crawl-body').append(text);
$('.crawl-body').iCheck();

the weird thing I noticed is that with the developper tool, it's as if a icheck checkbox was there but nothing was shown.

thanks if you could share ideas with me

I'm not english so don't shout if there's some mistakes, just edit please




Quiz website in java and jsp - How to select a right answer in multiple questions and get result?

I'm new at programming in java and currently in the process of creating a dynamic web project using Eclipse and mySQL Workbench. The website is going to be a quiz with five questions with four options each. The quiz itself is stored in a table in mySQL Workbench and accesable through the QuestionsDAO-file. Currently I'm having problems figuring how to assign one option as the correct answer in each of the questions in the array and how to print out the result of the quiz when you press the submit button in the jsp-file.

This is the body of jsp-file for the quiz

<%

ArrayList<Questions> quizArray =  null;

quizArray = QuestionsDAO.getAllQuestions();

int a = 1;
int o1 = 1;
int o2 = 2;
int o3 = 3;
int o4 = 4;
int qnr = 1;

for(Questions question : quizArray) {   
%>

if(request.getParameter("resultBtn") != null){

int correctAnswers = 0;


<tr>
    <td><p><%=qnr%>. <%=question.getQuestion() %></p></td>

    <td><%=question.getQoptOne() %></td>
    <input type="checkbox" id="<%= o1 %>" name="check1" value="check1"></input>
    </br>

    <td><%=question.getQoptTwo() %></td>
    <input type="checkbox" id="<%= o2 %>" name="check2" value="check2"></input>
    </br>
    <td><%=question.getQoptThree() %></td>
    <input type="checkbox" id="<%= o3 %>" name="check3" value="check3"></input>
    </br>
    <td><%=question.getQoptFour() %></td>
    <input type="checkbox" id="<%= o4 %>" name="check4"value="check4"></input>
    </br></tr>`<% } %>`



<form action="result.jsp" method="post">
    <input id="sendBtn" value="Submit" type="submit" name="resultBtn"></input>
    <input type="text" id="resultField" name="resultField"></input>
</form>

String answer1 = request.getParameter("1"); 
if(request.getParameter("check1") != null) {
    correctAnswers = correctAnswers + 1;
 } else {
    System.out.println("Wrong in question 1");
 }

String answer2 = request.getParameter("3"); 
if(request.getParameter("check3") != null) {
    correctAnswers = correctAnswers + 1;
 } else {
    System.out.println("Wrong in question 2");
 }

String answer3 = request.getParameter("2"); 
if(request.getParameter("check2") != null) {
    correctAnswers = correctAnswers + 1;
 } else {
    System.out.println("Wrong in question 3");
 }


String answer4 = request.getParameter("2");
if(request.getParameter("check2") != null) {
    correctAnswers = correctAnswers + 1;
} else {
    System.out.println("Wrong in question 4");
}

System.out.println("You have " + correctAnswers + " correct answers");}

The Questions-class

public class Questions {

long questionID;
String question;
String qoptOne;
String qoptTwo;
String qoptThree;
String qoptFour;
int correctAnswer;
private boolean isActive = true;

public Questions(long questionID, String question, String qoptOne, String qoptTwo, String qoptThree, String qoptFour, int correctAnswer){
    this(questionID, question, qoptOne, qoptTwo, qoptThree, qoptFour, correctAnswer, true);
}

public Questions(long questionID, String question, String qoptOne, String qoptTwo, String qoptThree, String qoptFour, int correctAnswer, boolean isActive){
    this.questionID = questionID;
    this.question = question;
    this.qoptOne = qoptOne;
    this.qoptTwo = qoptTwo;
    this.qoptThree = qoptThree;
    this.qoptFour = qoptFour;
    this.correctAnswer = correctAnswer;
    this.isActive = isActive;
}

public String getQuestion()
{ 
    return question;
}

public void setQuestion(String s)
{
    question=s;
}


public long getQuestionID()
{
    return questionID;
}

public void setQuestionNumber(int i)
{
    questionID = i;
}

public int getCorrectAnswer()
{
    return correctAnswer;
}

public void setCorrectAnswer(int i)
{
    correctAnswer=i;
}

public String getQoptOne()
{
    return qoptOne;
}

public String getQoptTwo()
{
    return qoptTwo;
}

public String getQoptThree()
{
    return qoptThree;
}

public String getQoptFour()
{
    return qoptFour;
}

}

The QuestionsDAO-class

public class QuestionsDAO {

static ArrayList<Questions> resultQuestions = new ArrayList<Questions>();

public static Questions getQuestion(){
    Questions result = null;
    Connection con = null;

try {

        con = JDBCConnectionFactory.getNewConnection();
        String sql = "SELECT * FROM quiz1 WHERE question LIKE ? OR q_id LIKE ? or o1 LIKE ? or o2 LIKE ? or o3 LIKE ? or o4 LIKE ?";
        java.sql.PreparedStatement prep = con.prepareStatement(sql);
        ResultSet res = prep.executeQuery();

        while(res.next()){
            String question = res.getString("quiz1.question");
            long questionID = res.getLong("quiz1.q_id");
            String qoptOne = res.getString("quiz1.o1");
            String qoptTwo = res.getString("quiz1.o2");
            String qoptThree = res.getString("quiz1.o3");
            String qoptFour = res.getString("quiz1.o4");
            resultQuestions.add(new Questions(questionID, question, qoptOne, qoptTwo, qoptThree, qoptFour, 0));
        }
    } catch(SQLException e){
        e.printStackTrace();
        } finally{
            JDBCConnectionFactory.closeConnection(con);
        }
    return result;
}


public static ArrayList<Questions> getAllQuestions(){
    ArrayList<Questions> result = new ArrayList<Questions>();
    Connection con = null;

    try{
        con = JDBCConnectionFactory.getNewConnection();
        String sql = "SELECT * FROM quiz1 ";
        java.sql.PreparedStatement prep = con.prepareStatement(sql);
        ResultSet res = prep.executeQuery();

        while(res.next()){
            String question = res.getString("quiz1.question");
            long questionID = res.getLong("quiz1.q_id");
            String qoptOne = res.getString("quiz1.o1");
            String qoptTwo = res.getString("quiz1.o2");
            String qoptThree = res.getString("quiz1.o3");
            String qoptFour = res.getString("quiz1.o4");
            result.add(new Questions(questionID, question, qoptOne, qoptTwo, qoptThree, qoptFour, 0));
        }
    } catch(SQLException e){
        e.printStackTrace();
    } finally{
        JDBCConnectionFactory.closeConnection(con);
    }
    return result;  
}


public static ArrayList<Questions> getOneQuestion(long searchLong){
    ArrayList<Questions> result = new ArrayList<Questions>();
    Connection con = null;

    try{
        con = JDBCConnectionFactory.getNewConnection();
        String sql = "SELECT * FROM quiz1 WHERE q_id LIKE ? ";
        java.sql.PreparedStatement prep = con.prepareStatement(sql);
        ResultSet res = prep.executeQuery();

        while(res.next()){
            String question = res.getString("quiz1.question");
            long questionID = res.getLong("quiz1.q_id");
            String qoptOne = res.getString("quiz1.o1");
            String qoptTwo = res.getString("quiz1.o2");
            String qoptThree = res.getString("quiz1.o3");
            String qoptFour = res.getString("quiz1.o4");
            result.add(new Questions(questionID, question, qoptOne, qoptTwo, qoptThree, qoptFour, 0));
        }
    } catch(SQLException e){
        e.printStackTrace();
    } finally{
        JDBCConnectionFactory.closeConnection(con);
    }
    return result;  
}

public static ArrayList<Questions> searchQuestions(String searchString) {
    ArrayList<Questions> results = new ArrayList<Questions>();

    Connection con = null;

    try{
        con = JDBCConnectionFactory.getNewConnection();
        String sql = "SELECT * FROM quiz1 WHERE question LIKE ? OR q_id LIKE ? or o1 LIKE ? or o2 LIKE ? or o3 LIKE ? or o4 LIKE ?";

        java.sql.PreparedStatement prep = con.prepareStatement(sql);
        prep.setString(1, searchString + "%");
        prep.setString(2, searchString + "%");
        ResultSet res = prep.executeQuery();
         while(res.next()){
             Questions question = createQuestionFromResult(res);
             results.add(question);
         }

    } catch (SQLException e){
        e.printStackTrace();
    } finally{
        JDBCConnectionFactory.closeConnection(con);
    }
    return results;
}

static Questions createQuestionFromResult(ResultSet res) throws SQLException{
    Questions result = null;

    String question = res.getString("quiz1.question");
    long questionID = res.getLong("quiz1.q_id");
    String qoptOne = res.getString("quiz1.o1");
    String qoptTwo = res.getString("quiz1.o2");
    String qoptThree = res.getString("quiz1.o3");
    String qoptFour = res.getString("quiz1.o4");
    result = new Questions(questionID, question, qoptOne, qoptTwo, qoptThree, qoptFour, 0);
    return result;



}

}




Angular 2: How to add required field validation on checkbox group?

I have 4 checkboxes in which at least one should be selected by the user. As I am new to angular so can someone please help me out in this.




Keeping Table Visible Throughout Session

I have a table where I can check a checkbox and it will log all of the contents in the row. Once you check a checkbox, another column (Quantity #) appears with a textbox/spinner inside the cell. If it is unchecked, then the corresponding textbox/spinner disappears (hidden).

I want to use session storage to be able to keep any cells in the Quantity # column visible throughout the session until the page is closed, but only if the row is checked. I was able to use session storage to keep the checkboxes checked, but am having a problem with getting the Quantity # column to remain visible as long as the checkbox is checked for that row.

How can I do this?

I have included the HTML for the checkbox row and the JavaScript that keeps the checkboxes checked so it can be used to base an answer off of if needed.

HTML for the checkbox and the appearing table cell:

<td class="ui-widget-content"><input type="checkbox" class="check" name="check" id="checkid-<?php echo intval ($row['ID'])?>"></td>
<td class="quantity_num ui-widget-content" name="rows[0][0][quant]" style="display: none;"><input type="textbox" style="width: 100px;" class="spinner" id="spin-<?php echo intval ($row['ID'])?>"></td>

JavaScript for the session storage for the checkbox and for the spinner in the appearing table cell:

$(function(){
    $(':checkbox').each(function() {
        // Iterate over the checkboxes and set their "check" values based on the session data
        var $el = $(this);
        $el.prop('checked', sessionStorage[$el.prop('id')] === 'true');
    });

    $('input:checkbox').on('change', function() {
        // save the individual checkbox in the session inside the `change` event, 
        // using the checkbox "id" attribute
        var $el = $(this);
        sessionStorage[$el.prop('id')] = $el.is(':checked');
    });
});


$(function () {
    $(".check").change(function(){
    $(this).closest('tr').find('td.quantity_num').toggle(this.checked);
    console.log($('input.check').is(':checked'));
    var quantity = $(this).closest('tr').find('td.quantity').data('quantity');
        console.log(quantity);

  if($('input.check').is(':checked'))
    $(this).closest('table').find('th.num').toggle(true);
    else
    $(this).closest('table').find('th.num').toggle(false);



    $(this).closest("tr").find(".spinner" ).spinner({
      spin: function( event, ui ) {
        if ( ui.value > quantity ) {
          $( this ).spinner( "value", quantity );
          return false;
        } else if ( ui.value <= 1 ) {
          $( this ).spinner( "value", 1 );
          return false;
        }
      }
    });
  });
  });

HTML/PHP for table:

<table id="merchTable" cellspacing="5" class="sortable">
    <thead>
        <tr class="ui-widget-header">
            <th class="sorttable_nosort"></th>
            <th class="sorttable_nosort">Loc</th>
            <th class="merchRow">Report Code</th>
            <th class="merchRow">SKU</th>
            <th class="merchRow">Special ID</th>
            <th class="merchRow">Description</th>
            <th class="merchRow">Quantity</th>
            <th class="sorttable_nosort">Unit</th>
            <th style="display: none;" class="num">Quantity #</th>
        </tr>
    </thead>
    <tbody>

        <?php foreach ($dbh->query($query) as $row) {?>

        <tr>
            <td class="ui-widget-content"><input type="checkbox" class="check" name="check" id="checkid-<?php echo intval ($row['ID'])?>"></td>
            <td class="loc ui-widget-content"><input type="hidden"><?php echo $row['Loc'];?></td>
            <td name="rows[0][0][rp-code]" class="rp-code ui-widget-content" align="center" id="rp-code-<?php echo intval ($row['Rp-Code'])?>"><?php echo $row['Rp-Code'];?></td>
            <td name="rows[0][0][sku]" class="sku ui-widget-content" id="sku-<?php echo intval ($row['SKU'])?>"><?php echo $row['SKU'];?></td>
            <td name="rows[0][0][special-id]" class="special-id ui-widget-content" align="center" id="special-id-<?php echo intval ($row['Special-ID'])?>"><?php echo $row['Special-ID'];?></td>
            <td name="rows[0][0][description]" class="description ui-widget-content" id="description-<?php echo intval ($row['Description'])?>"><?php echo $row['Description'];?></td>
            <td name="rows[0][0][quantity]" class="quantity ui-widget-content" data-quantity="<?php echo $row['Quantity'] ?>" align="center" id="quantity-<?php echo intval ($row['Quantity'])?>"><?php echo $row['Quantity'];?></td>
            <td name="rows[0][0][unit]" class="unit ui-widget-content" id="unit-<?php echo intval ($row['Unit'])?>"><?php echo $row['Unit'];?></td>
            <td name="rows[0][0][quant]" style="display: none;" class="quantity_num ui-widget-content"><input type="textbox" style="width: 100px;" class="spinner" id="spin-<?php echo intval ($row['ID'])?>"></td>
        </tr>

    <?php } ?>

    </tbody>
</table>




Get dynamic group of checkboxes grouped by an attribute

im developing an ACL manager and permissions on ACL GUI are created dynamically based on controllers in database. So if they are 3 controllers for example, I get 3 groups of 4 checkboxes (read, write, delete, execute). They have different ids, value based on checkbox (read=r, write=w...) and same data-id as controller id.

enter image description here

<ul class="list-group">
home                    
<li class="list-group-item">
    Read
    <div class="material-switch pull-right">
        <input id="check_permisssion_read1" class="acl_permission" type="checkbox" name="acl_permission[]" value="r" data-id="1">
        <label for="check_permisssion_read1" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Write
    <div class="material-switch pull-right">
        <input id="check_permisssion_write1" class="acl_permission" type="checkbox" name="acl_permission[]" value="w" data-id="1">
        <label for="check_permisssion_write1" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Delete
    <div class="material-switch pull-right">
        <input id="check_permisssion_delete1" class="acl_permission" type="checkbox" name="acl_permission[]" value="d" data-id="1">
        <label for="check_permisssion_delete1" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Execute
    <div class="material-switch pull-right">
        <input id="check_permisssion_execute1" class="acl_permission" type="checkbox" name="acl_permission[]" value="e" data-id="1">
        <label for="check_permisssion_execute1" class="label-success"></label>
    </div>
</li>
acl                    
<li class="list-group-item">
    Read
    <div class="material-switch pull-right">
        <input id="check_permisssion_read2" class="acl_permission" type="checkbox" name="acl_permission[]" value="r" data-id="2">
        <label for="check_permisssion_read2" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Write
    <div class="material-switch pull-right">
        <input id="check_permisssion_write2" class="acl_permission" type="checkbox" name="acl_permission[]" value="w" data-id="2">
        <label for="check_permisssion_write2" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Delete
    <div class="material-switch pull-right">
        <input id="check_permisssion_delete2" class="acl_permission" type="checkbox" name="acl_permission[]" value="d" data-id="2">
        <label for="check_permisssion_delete2" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Execute
    <div class="material-switch pull-right">
        <input id="check_permisssion_execute2" class="acl_permission" type="checkbox" name="acl_permission[]" value="e" data-id="2">
        <label for="check_permisssion_execute2" class="label-success"></label>
    </div>
</li>
acl_funcion1                    
<li class="list-group-item">
    Read
    <div class="material-switch pull-right">
        <input id="check_permisssion_read3" class="acl_permission" type="checkbox" name="acl_permission[]" value="r" data-id="3">
        <label for="check_permisssion_read3" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Write
    <div class="material-switch pull-right">
        <input id="check_permisssion_write3" class="acl_permission" type="checkbox" name="acl_permission[]" value="w" data-id="3">
        <label for="check_permisssion_write3" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Delete
    <div class="material-switch pull-right">
        <input id="check_permisssion_delete3" class="acl_permission" type="checkbox" name="acl_permission[]" value="d" data-id="3">
        <label for="check_permisssion_delete3" class="label-success"></label>
    </div>
</li>
<li class="list-group-item">
    Execute
    <div class="material-switch pull-right">
        <input id="check_permisssion_execute3" class="acl_permission" type="checkbox" name="acl_permission[]" value="e" data-id="3">
        <label for="check_permisssion_execute3" class="label-success"></label>
    </div>
</li>

So when I click on save button, I need to get checked checkboxes but grouped by data-id, how can I get this?

I only got looping all checkboxes and checking if is checked, if is, return data-id+value (1r, 1w...) for example.

var checkboxes = $('.acl_permission');
        checkboxes.each(function(idx, el){
            if ($(this).is(':checked')) {
                console.log($(this).data('id') + $(this).val())
            }
        });

But like this, im getting:

1r
1w
2r
2w
3w

I would like to get something like:

[{data-id: 1, permissions: 'rw'}, {data-id: 2, permissions: 'rw'}, {data-id: 3, permissions: 'w'}] based on data-id (controller id) and permissions checked on that data-id (r,w,d,e).

Thanks!!




lundi 29 mai 2017

Checkbox value is true but tick is not showing - Android / Java

Basically here I have three(3) checkbox list in three(3) different fragment. When I open the activity, my checkbox in the default fragment display like normal, but the one in different fragment display differently. The value of the checkbox is still true. Below is the image for the checkbox to make things clearer and also my code.

First fragment page:

enter image description here

Second fragment page:

enter image description here

Code for setting up the checkbox and its if condition

private void setCheckBox(ArrayList<DataPrefType> arrayList){
    for(int i = 0; i < arrayList.size(); i++){
        id = i + 1;
        checkBox = new CheckBox(getActivity());
        checkBox.setId(i + 1);
        checkBox.setText(arrayList.get(i).getName());
        checkBox.setPadding(10, 10, 10, 10);
        checkBox.setLayoutParams(params);
        checkBox.setGravity(Gravity.CENTER);
        checkBoxLayout.addView(checkBox);

        if(!userPreference.isEmpty() || userPreference != null){
            for(int j = 0; j < userPreference.get(0).getDataPrefTypeArrayList().size(); j++){
                int retrieveId = Integer.parseInt(userPreference.get(0).getDataPrefTypeArrayList().get(j).getId());
                if(checkBox.getId() == retrieveId)
                    checkBox.setChecked(true);
            }
        }




How to create checkbox tree in angular2

Basic Problem

  • I am new to angular2 and wanted to create checkbox tree to get some understanding.
  • I am achieved this by code shared in the question. Now I want is, when parent checkbox is checked. it should automatically check all children checkboxes.
  • Also changing all the values in backend data available on service.

I tried a lot hence creating a lot of confusing code so now I have removed weird code and want to try it again with experts advice.
Please Help me thankyou

1-Made a class category

  export class Category {
  constructor(public text:string,public value:Boolean|Array<Category>=false,  
 public id:string="auto" ,public name:string ="auto" )
   {

}}

2-Made a service to provide data

  export class ProvideDataService{

  constructor() {

this.categories.push(this.cate1);
this.categories.push(this.cate2);
this.categories.push(this.cate3);

}

private categories: Array<Category> = [];

private date1: Category = new Category("Wood");
private date2: Category = new Category("Alumiam");
private date3: Category = new Category("Plastic");
private date1Array: Array<Category> = [this.date1, this.date2, this.date3];
private f1: Category = new Category("Chairs", this.date1Array);
private f2: Category = new Category("Tables", false, true, true, "t", "t");
private f3: Category = new Category("Bed", false, true, true, "b", "b");

private cate1Array: Array<Category> = [this.f1, this.f2, this.f3];

private cate1: Category = new Category("Furniture", this.cate1Array, true, true, "f", "f");
private cate2: Category = new Category("Medical", false, true, true, "m", "m");
private cate3: Category = new Category("Beauty", false, true, true, "be", "be");
}

3- Created Checkbox Tree Component.Following is TemplateUrl HTML File

 <!--Root Layer-->
 <ul *ngFor="let a of categories">
   <li>
     <sr-check-box-category [c]="a">Loading...</sr-check-box-category>
     <!--Second Layer-->
        <sr-check-box-tree *ngIf="onSwitch(a.value)" [categories]="a.value">Loading...</sr-check-box-tree>
   </li>
 </ul>

4-Created Checkbox component

@Component({
selector: 'sr-check-box-category',
styleUrls: ['./check-box-category.component.css'],
template: `
<input  [attr.id]="c.id" [attr.name]="c.name"  ng-checked='c.value' 
(change)="onCheckChanged(c.id,$event)"  type="checkbox" />  
  `
      })

   export class CheckBoxCategoryComponent implements OnInit {

   constructor(private service: SelectedCheckBoxesService) { }
  @Input() c: Category = null;

 }

5- Added CheckBox Tree Component in Parent Component

 @Component({
 selector: 'sr-search-bar',
 template:`
 <sr-check-box-tree [categories]="categories" [IsParentOn]="false"></sr-check-box-tree>`,

providers: [SelectedCheckBoxesService]
})

export class SearchBarComponent {

 private categories:Array<Category>=[];
 constructor(private service:SelectedCheckBoxesService) { 

  this.categories=this.service.Get();

 }

 }

`




Oracle ADF : Select Check box at row level giving issue while selecting in panel tabbed

I am referring to this blog. http://ift.tt/2qvoCCK however my requirement is different. I have multiple tabs where multiple tables are present. In each table row I need a column attribute is_active in checkbox format. So basically I want to store active or non active setup lines through panel tabbed screens.

With above blog approach first tab is working fine for checkboxes, but the second , third and other tabs are having below issues in check box.

When selected one checkbox, let's say it is checked, other checkboxes in all rows gets checked.

I checked the binding it is bind to it's respective attributes and VO iterators in pagedefinition, I chceked the code for model and view layer for working and non working tab.

please help.




Creation Dynamic checkboxes Javascript

I've got an issue that I don't understand.

I'm creating a "generator" of checkboxes based on an array.

                        var array = new Array();
                        array[0]="Monday";
                        array[1]="Tuesday";
                        array[2]="Wendesday";
                        array[3]="Thirsday";
                        array[4]="Friday";
                        array[5]="Saturday";
                        array[6]="Sunday";

                        var cbh = document.getElementById('checkboxes');
                    var val = '';
                    var cap = '';
                    var cb = document.createElement('input');

                    var j = "";
                        for (var i in array) {
                                //Name of checkboxes are their number so I convert the i into a string. 
                                j = i.toString();
                                console.log('J = ', j);
                                val = j;
                                //cap will be the value/text of array[i]
                                cap = array[i];
                                console.log('cap =', cap);


                            cb.type = 'checkbox';
                            cbh.appendChild(cb);
                            cb.name = val;
                            cb.value = cap;
                            cbh.appendChild(document.createTextNode(cap));
                        }
                      * {
                        box-sizing: border-box;
                        }
                        #data {
                            padding:0;
                                width:100vw;
                        }
                        .multiselect {
                                overflow: visible;
                                padding:0;
                                padding-left:1px;
                                border:none;
                                background-color:#eee;
                                width:100vw;
                                white-space: normal;
                                height:200px;
                        }
                        .checkboxes {
                                height:100px;
                                width:100px;
                                border:1px solid #000;
                                background-color:white;
                                margin-left:-1px;
                                display:inline-block;
                        }
                </style>
<form>
                        <div id="data">
                                <div class="multiselect">
                                         <div id="checkboxes">
                                        </div>
                                </div>
                        </div>
                </form>
(the CSS is not important for my problem... I think)

The problem is that it creates only one checkboxe, for the last element and I don't understand why... I would like a checkboxe for each day.

After that I'm asking how to retrieve the element select, but this is in a second part.

So If someone has an idea, I would be thanksfull !

regards.




C# Can't find checkbox in Controls (System.Web.UI.Control)

I'm trying to select the drawings that a user made, so I start like this:

while (reader.Read())
{
    System.Web.UI.WebControls.CheckBox checkb = new System.Web.UI.WebControls.CheckBox();
    DropForm.Controls.Add(new LiteralControl("<br/>Desenho "+ (i +1) +":  "));
    DropForm.Controls.Add(checkb);
    Button1.Visible = true;
    i = i + 1;
}

And when the user clicks the button:

public void Button1_Click(object sender, EventArgs e)
{
    foreach (System.Web.UI.Control control in DropForm.Controls)
    {
        if (control is System.Web.UI.WebControls.CheckBox)
        {
            if (((System.Web.UI.WebControls.CheckBox)control).Checked == true)
            {
                Response.Write("Yes");
            }
            else
            {
                Response.Write("no");
            }
        }
        else
        {
            Response.Write("cicle");
        }
     }
 }

I have 13 Controls on the page so it shows 13 'cicle', but it's not recognizing any checkbox, am I doing something wrong?




custom adapter with Checkbox

I`m trying to delete the selected item in listView when user check its checkbox

I just cant figure out how can i get the position of the selected item when the checkbox checked. here is my custom-adapter :

public class StudentsAdapter extends BaseAdapter {

private List<Students> _studetns;
private Context _Context;

public StudentsAdapter(List<Students> _studetns, Context _Context) {
    this._studetns = _studetns;
    this._Context = _Context;
}

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

@Override
public Object getItem(int position) {
    return _studetns.get(position);
}

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

class ViewHolder{
   private TextView studentId;
   private  TextView studentName;
   private  TextView studentLastName;
    private CheckBox checkBox;

   public ViewHolder(View v)
   {
       studentId = (TextView) v.findViewById(R.id.lblId);
       studentName= (TextView) v.findViewById(R.id.lblName);
       studentLastName= (TextView) v.findViewById(R.id.lblLastName);
       checkBox = (CheckBox) v.findViewById(R.id.checkBox);
   }

}

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

    Students item = _studetns.get(position);
    View myLayout = View.inflate(_Context,R.layout.activity_student,null);

    ViewHolder holder = new ViewHolder(myLayout);

    holder.studentId.setText(String.valueOf(item.get_studentId()));
    holder.studentName.setText(item.get_studentName());
    holder.studentLastName.setText(item.getStudentLastName());
    holder.checkBox.setTag(position);
    return myLayout;
}

}




Hiding/showing class content if checkbox is ticked

Can't seem to get the checkbox section working.

The .hide() works fine, but the else refuses to show it again.

Other versions of the same code mess up other bits of script on the page, and toggle is a no go due to loading time (if a visitor clicks it too early it ends up reversed!)

Essentially, all I'm looking for is to hide the content if the checkbox is ticked, and to show it again if it's unticked.

jQuery(document).ready(function($) {

    $('.sponsor_table').hide();
    $('.sponsor_address').hide();
    $('input[type="checkbox"]').click(function(){
        if($('input[name="anonymous_sponsor"]:checked')) {
            $('.sponsor_name').hide();
            $('.sponsor_logo').hide();
            $('.sponsor_website').hide();
        } else {
            $('.sponsor_name').show();
            $('.sponsor_logo').show();
            $('.sponsor_website').show();
        }
     });
    $('input[type="radio"]').click(function(){
        if($('input[name="cb_sponsor_attendance"]:checked').val() == "Yes"){
            $('.sponsor_table').fadeIn('slow');
            $('.sponsor_address').hide();
        }
        else if($('input[name="cb_sponsor_attendance"]:checked').val() == "No"){
            $('.sponsor_address').fadeIn('slow');
            $('.sponsor_table').hide();
        }
    });

});




check-box checked div should display with list of radio button on check of radio button both value to be alerted

I have a list of check box on check of each check-box list of radio button will appear . on select of radio button . i need value of check box and radio button . it should work for multiple check boxes.




Select dynamic checkbox with the given selected number at every item of Recycle view

Here i have data like menu item has multiple categories and multiple category has multiple items now my problem is the items will be selected by the given selected no. which are given with the categories.

here is the image.In picture Soup is a category and every category has multiple item and the selection no is coming with the category name.Every category has different selection no. and every card is a row of recycle view in which check box is created dynamically here is my Adapter

public class MenuAdapter extends RecyclerView.Adapter<MenuAdapter.MenuHolder> {


public static ArrayList<CartItemBean> cartItemBeanArrayList;
public static ArrayList<CartBean> cartList = new ArrayList<>();
public static CartItemBean cartItemBean;
public static CartBean cartBean;
public static String item, category, id;
Button addmenu_btn;
int listsize;
String select;
int selectInt;
int numChecked = 0;
CheckBox checkBox;
private List<MenuBean> menulist;
private Context mContext;


public MenuAdapter(Context context, List<MenuBean> menulist) {
    this.menulist = menulist;
    this.mContext = context;

}

@Override
public MenuHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.rowitem_menu, null);
    v.setLayoutParams(new RecyclerView.LayoutParams(
            RecyclerView.LayoutParams.MATCH_PARENT,
            RecyclerView.LayoutParams.WRAP_CONTENT
    ));
    MenuHolder mh = new MenuHolder(v, mContext);
    return mh;
}

@Override
public void onBindViewHolder(MenuHolder menuHolder, final int i) {

    final ArrayList itemlist = menulist.get(i).getItemBeansList();
    listsize = itemlist.size();

    menuHolder.menutitle.setText(menulist.get(i).getCategory());
    menuHolder.menuitemselect.setText("Select-" + menulist.get(i).getNitem());
    menuHolder.lnr_view.removeAllViews();

    select = menulist.get(i).getNitem();
    selectInt = Integer.valueOf(select);

    cartItemBean = new CartItemBean();
    cartItemBeanArrayList = new ArrayList<>();
    cartBean = new CartBean();

    for (int k = 0; k < itemlist.size(); k++) {

        checkBox = new CheckBox(mContext);
        checkBox.setId(Integer.parseInt(menulist.get(i).getItemBeansList().get(k).getId()));
        checkBox.setText(menulist.get(i).getItemBeansList().get(k).getItem());
        menuHolder.lnr_view.addView(checkBox);

        final int finalK = k;
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {


                if (isChecked) {

                    numChecked++;
                    Log.e("numChecked::::", "" + numChecked);
                    item = buttonView.getText().toString();
                    Log.e("CheckItem", item);
                    category = menulist.get(i).getCategory();
                    Log.e("Check Category", category);
                    id = menulist.get(i).getItemBeansList().get(finalK).getId();
                    Log.e("Check Id", id);

                    cartItemBean.setCategoryName(category);
                    cartItemBean.setCategoryItem(item);
                   /* //cartItemList.add(item);
                    //cartBean.setCategoryItem(item);
                   // cartBean.setCartItem(cartItemList);
                   // cartBean.setCategoryName(category);
                   // cartBean.setId(id);*/
                    cartItemBeanArrayList.add(cartItemBean);


                } else {
                    numChecked--;
                    cartItemBeanArrayList.remove(cartItemBean);
                    //  cartList.remove(cartBean);
                }
            }
        });

    }

}


@Override
public int getItemViewType(int position) {

    return super.getItemViewType(position);
}

@Override
public int getItemCount() {
    return (null != menulist ? menulist.size() : 0);
}

class MenuHolder extends RecyclerView.ViewHolder {

    protected TextView menutitle, menuitemselect;
    CardView menucardview;
    LinearLayout lnr_view;

    public MenuHolder(View itemView, final Context mContextv) {
        super(itemView);

        lnr_view = (LinearLayout) itemView.findViewById(R.id.lnr_view);
        menutitle = (TextView) itemView.findViewById(R.id.menutitle);
        menucardview = (CardView) itemView.findViewById(R.id.menucardview);
        menuitemselect = (TextView) itemView.findViewById(R.id.menuitemselect);

    }

}

}




Checkbox size makes other elements drop under the line

I have a form group, it contains of an input field with an addon, a checkbox with an image and a button next to them, they're displayed next to each other, but when i give my checkbox height and width the image and the button move down i don't know why, how can i fix that? here is my code:

.box{
height: 34px;
width: 34px;
}

.btn-default{
height: 34px;
width: 34px;
}
<div class="col-lg-12 form-group">
  <div class="pull-right">
    <img src="http://ift.tt/2qroZ5g"><input type="checkbox" class="box">
  <button type="button" class="btn btn-default">+</button>
</div>
<div>
<div class="input-group">
  <span class="input-group-addon">@</span>
    <input type="text" class="form-control"/>
</div>
</div>
</div>



dimanche 28 mai 2017

Can't click on label to select checkbox with Bootstrap checkbox layout

So I have the following code:

// the loop
                $countId = 0;
                $dateOnce = '';
                foreach ($postDates as $post):
                    if (substr($post->post_date, 0, 7) != $dateOnce) {
                        echo'
                            <div class="checkbox">
                                <label for="filterByPostDate-' . $countId . '">
                                    <input type="checkbox" id="filterByPostDate-' . substr($post->post_date, 0, 7) . '" class="postDateFilters postDateFilterCb-' . $countId . '" name="filterByPostDate-' . $countId . '" value="' . substr($post->post_date, 0, 7) . '" '; if (isset($_SESSION["filterByPostDate"])) { $key = array_search(substr($post->post_date, 0, 7), $_SESSION["filterByPostDate"]); } else { $key = false; } if($key !== false) { echo 'checked'; } echo ' />
                                    ' . date('M, Y', strtotime($post->date_part)) . '
                                </label>
                            </div>
                        ';
                    }
                    $dateOnce = substr($post->post_date, 0, 7);
                $countId++;
                endforeach;
                // END the loop

Which outputs checkboxes and labels for the wordpress frontend. But when I click on the label for each checkbox the checkbox doesn't get selected.

Here is a js fiddle which shows the problem.

Cheers for the help.




Change the multiple choice list item checkbox tint

I have a list view with choice mode set to multiple. I have set the layout to simple_list_item_multiple_choice. It gives the checkboxes in the right side of the row.

But here's the problem: button tint of these checkboxes is terrible blue (which is far from my application color scheme). Whatever I do, I can't change it. I have already tried: creating a style for CheckBox and creating a style for CheckedTextView, changing there all kinds of button tints and color accents. None of it works. What should I do?

A piece of layout:

...
   <ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/listView1"
    android:layout_weight="1"
    android:choiceMode="singleChoice" /> ...

A piece of activity code:

  ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(),
  android.R.layout.simple_list_item_multiple_choice, players);
  itemsList.setAdapter(adapter);

Solutions I've tried:

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:colorPrimary">@color/MainColor</item>
    <item name="android:colorAccent">@color/colorAccent</item>
    <item name="android:textColor">@color/MainColor</item>
    <item name="colorAccent">@color/MainColor</item>
    <item name="colorPrimary">@color/MainColor</item>
    <item name="android:checkboxStyle">@style/CheckBoxStyle</item>
    <item name="android:checkedTextViewStyle">@style/CheckedTextViewStyle</item>
</style>
<style name="CheckBoxStyle" parent="AppTheme">
    <item name="android:tint">@color/colorAccent</item>
    <item name="android:buttonTint">@color/colorAccent</item>
</style>

<style name="CheckedTextViewStyle" parent="AppTheme">
    <item name="android:colorButtonNormal">@color/colorAccent</item>
    <item name="android:checkMarkTint">@color/colorAccent</item>
    <item name="android:tint">@color/colorAccent</item>
    <item name="android:buttonTint">@color/colorAccent</item>
    <item name="android:colorAccent">@color/colorAccent</item>
</style>




Bootstap Popover Change Checkbox via JS / JQUERY

I don't get this problem solved.

I have a page with a list of users. On each User you can change some status - for exemple 'follow'. For this i am using Bootstrap Popover in which i placed some checkboxes.

     <button type="button" class="btn btn-primary user-popover" 
          data-user-id="" 
          data-toggle="popover" 
          title="Title" 
          data-placement="bottom" 
          data-content="
               <fieldset class='form-group'>
                    <input type='checkbox' 
                         id='check_follow_' 
                         data-update='relation' 
                         data-name='follow' 
                         data-id='' 
                         name='relation' 
                         value='follow' 
                         @if($user->follow) checked @endif >
                    <label for='check_follow_'>
                         Follow User</label>
               </fieldset>
          ">
          Friend
     </button>

On the Event 'shown.bs.popover' i defined a Listener with is updating the database and since the value of the Checkbox is not persisting during the hide of the popover i created an array for all the users shown on this page which i change.

 window.user_data = [{
     id: 1,
     follow: true
 }];

Until here all is working well. Now i also try to check or uncheck the checkbox depending on the data. Therefore i also added to the 'shown.bs.popover' event this Code:

 const id = $(this).data('user-id');
 const array = window.user_data;
 const result = $.grep(array, function(e){ return e.id === id;});
 if (result.length >= 0) {
      $('#ckeck_follow_'+id).prop("checked", result[0].follow);
 }

But this is not working. I tryed with output in the console if the data of the array is right, if i find the checkbox element - all good

But the checkbox doesn't change.

Any Idea?