dimanche 31 décembre 2017

Limit checks in DataGridView CheckBox

I have a DataGridView with CheckBox, now my question is how do I set a limit on how many CheckBox can be checked into say like 3? I already have the code for counting how many CheckBox is checked. I am new to programming and sorry for my bad english.

private void DataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
        bool isChecked = Convert.ToBoolean(DataGridView1.Rows[DataGridView1.CurrentCell.RowIndex].Cells[0].Value.ToString());

        if (isChecked)
        {
            num += 1;
        }
        else
        {
            num -= 1;
        }
        MessageBox.Show(num.ToString());
    }




JSF 1.1 - How to get the ID attribute of h:selectBooleanCheckbox in backing bean Edit 2

So, here is the jsf component:

<h:selectBooleanCheckbox id="cb#{index}" value="#{backingBean.value}" />

And here is a part of the backing bean java:

/**
 * getValue is a method which checks if a checkbox is selected or not, using the checkbox ID
 */
public boolean getValue() { 
  //TODO: get the checkbox id
  String checkboxID = ??

  if (getCheckedIDs().contains(checkboxID)) {
    return true;
  }

  return false;
}

When the page is loading the checkboxes, I want to check this way if the checkbox is selected or not. So the question is, what to write instead of ?? to get the ID of the checkbox who called the method? It's very important that I can use only JSF 1.1, so there are many solutions which won't work with this version.

Another very important thing is, that I cannot use the setter/getter in backing bean like here: http://ift.tt/2CqsRIW, because I need to store the value of the checkbox immediately after it's checked or unchecked, not only after submit. I have already resolved the storing in backing bean right after checking, I only need to send back true or false when loading page.
This is because I use a page navigation, and for example, when I check a box in page 1, and go to another page, and then go back, the box isn't selected anymore (only in backing bean).




samedi 30 décembre 2017

How to create a CheckBoxFor with boolean data type in razor view MVC?

My RadiobuttonFor

I have a radiobuttonfor like this :

@Html.RadioButtonFor(model => model.bit_isactive_user, true) Active @Html.RadioButtonFor(model => model.bit_isactive_user, false) NotActive

Can some one help me to solve this. how to make checkboxlistfor check for true condition and uncheck for false condition. Thanks




Visual Basic: reference label control from variable derived from checkbox control

I'm writing a simple Windows Form app in VB using VS Community 2017.

I have 64 checkboxes with 64 associated labels, named chk1 / lbl1 up to chk64 / lbl64. When a checkbox is checked, I want to extract a character from a string and show the answer in the label: e.g. if chk12 is checked, I want lbl12 to be enabled and the text to display the 12th character of the string.

To save writing 64 separate handlers I'm trying to do it in one. I can extract the checked number (e.g. 12) OK and write it to a string, but when I try to manipulate the label control I get an 'Object reference not set to an instance of an object' error.

The code I've come up with so far (largely from searching in here) is:

Private Sub CheckedChanged(sender As Object, e As EventArgs) _
  Handles chk1.CheckedChanged, chk2.CheckedChanged 'etc. to 64

    ' wanted behaviour
    'If chk1.Checked Then
    '    lbl1.Enabled = True
    '    lbl1.Text = GetChar(userString, 1)
    'End If
    'If chk2Checked Then
    '    lbl2.Enabled = True
    '    lbl2.Text = GetChar(userString, 2)
    'End If
    ' etc. (to 64)

    Dim resultsLabel As String
    Dim userCheckedBox As Integer

    userCheckedBox = CInt(DirectCast(sender, CheckBox).Text)
    resultsLabel = "lbl" & DirectCast(sender, CheckBox).Text

    Me.Controls(resultsLabel).Enabled = True
    Me.Controls(resultsLabel).Text = GetChar(userString, userCheckedBox)

End Sub

I'd be very grateful if someone can nudge me over the line with this. Many thanks!




php - How to delete row of table from sql database upon check of checkbox?

I have an HTML table created with Bootstrap with checkboxes fetching data from an sql database and if the checkbox is checked, the row is copied to another table below that one with js.

Also, how would I add the row to a new sql database? I know this requires php, but am not sure where to put it.

How would I delete the copied row from the mySQL database? Thanks in advance.

<html>
    <head>
        <title> Dashboard</title>
        <link type="text/css" href="css/bootstrap.min.css" rel="stylesheet">
        <link type="text/css" href="css/bootstrap-table.css" rel="stylesheet">
        <link type="text/css" href="css/font-awesome.css" rel="stylesheet">
        <link rel="stylesheet" type="text/css" href="custom.css">
</head>
<body>
<div class="container">
    <div class="col-md-12">
        <div class="panel panel-success">        
            <div class="panel-body">
                <div class="row">
                    <div class="col-md-12">

                        <table  id="table"
                                data-show-columns="true"
                                data-height="460">
                        </table>
                    </div>
                </div>
            </div>              
        </div>

    </div>
</div>
            <table id="duplicate" class="table table-striped">
      <thead>
        <tr>
          <th>
            #
          </th>
          <th>
            registrant
          </th>
        </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-table.js"></script>
<script type="text/javascript">
    var x=0;
     var $table = $('#table');
             $table.bootstrapTable({
                  url: 'list-leads.php',
                  search: true,
                  pagination: true,
                  buttonsClass: 'primary',
                  showFooter: true,
                  minimumCountColumns: 2,
                  columns: [{
                      data: '',
                      title: '',
                      checkbox: true,
                  },{
                      field: 'num',
                      title: '#',
                      sortable: true,
                  },{
                      field: 'registrant',
                      title: 'registrant',
                      sortable: true,
                  },  ],
 }).on('check.bs.table', function(row, element) {
  if (x <= 10) { $('#duplicate > tbody:last-child').append('<tr><td>' + element.num + '</td><td>' + element.registrant + '</td></tr>');x++;}

             });

</script>
</body>
</html>




vendredi 29 décembre 2017

Issue: Two checkbox are checked at a time while select any checkbox in RecyclerView Adapter, Android

Now I am using RecyclerView with CheckBox. My Goal is get selected Checkbox list. Here My Problem is while I try to select any one Checkbox means it select two Checkbox at the same time. For example I am select in 0th position Checkbox but It automatically select 0th and 13th Both position Checkbox are getting selected.

Here I have to attached my RecyclerView Adapter Class. Please any one help me..

Thanks in Advance.

public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {

    private ArrayList<ModuleViewModel> items =  new ArrayList<>();
    private OnItemCheckListener onItemClick;
    private Context mContext;

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_modules_list, parent, false);

        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(final MyViewHolder holder, final int position) {
        final ModuleViewModel currentItem = items.get(position);
        holder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                    holder.checkbox.setChecked(
                            ! holder.checkbox.isChecked());
                    if ( holder.checkbox.isChecked()) {
                        onItemClick.onItemChecked(currentItem);
                    } else {
                        onItemClick.onItemUnchecked(currentItem);
                    }
            }
        });
    }

    @Override
    public int getItemCount() {
        return items.size();
    }

    public interface OnItemCheckListener {
        void onItemChecked(ModuleViewModel item);
        void onItemUnchecked(ModuleViewModel item);
    }

    public MyAdapter (Context context,ArrayList<ModuleViewModel> items, @NonNull OnItemCheckListener onItemCheckListener) {
        this.mContext = context;
        this.items = items;
        this.onItemClick = onItemCheckListener;
    }


    static class MyViewHolder extends RecyclerView.ViewHolder {
        CheckBox checkbox;
        View itemView;

        public MyViewHolder(View itemView) {
            super(itemView);
            this.itemView = itemView;
            checkbox = (CheckBox) itemView.findViewById(R.id.uiCkbModule);
            checkbox.setClickable(false);

        }

        public void setOnClickListener(View.OnClickListener onClickListener) {
            itemView.setOnClickListener(onClickListener);
        }
    }
}

This is My Adapter calling Code

mModuleListAdapter = new ModuleListAdapter(mContext, mModuleListModel, this);
 mRvModuleView.setAdapter(mModuleListAdapter);




One Javascript code stops firing when another is triggered

My coworker and I are working on this page: http://ift.tt/2EaI9zI.

Because Blackbaud Netcommunity doesn't let us choose a dropdown display for the CFI Branch affiliation option, we thought we could write our own dropdown and sync it up with the checkboxes, then hide the checkboxes with CSS. (We have unhid the unsightly checkboxes for purposes of troubleshooting)

We got that part working but there is another piece of Javascript on that page that syncs up the One-time vs Recurring payment options. Whenever someone picks recurring payment and then adjusts the branch dropdown, the checkboxes no longer respond. The javascript for the dropdown/checkbox sync also doesn't work if the dropdown is adjusted after submitting the form with errors.

How can we restart this javascript file in these situations?




AngularJs - Select checkboxes by binding list of selected objects to list of all objects

I have searched for a solution to my problem but have not been able to find the right answer.
I have a list of all questions and a list of selected questions. I need to build a list of checkboxes from the list of all questions and check the ones that are in the list of selected questions. When changes are made to the checkboxes, I need the list of selected questions to be updated accordingly. The list of all questions never changes. How can I accomplish this? Here's a very abbreviated version of my situation:

        var MyApp = angular.module('MyApp', []);

        MyApp.controller('MyController', ['$scope', function ($scope) {

            $scope.allQuestions = [
                { q_id: 1, q_txt: 'What time is it?', q_sort: 1, selected: false },
                { q_id: 2, q_txt: 'What is that?', q_sort: 2, selected: false },
                { q_id: 3, q_txt: 'Who are you?', q_sort: 4, selected: false },
                { q_id: 4, q_txt: 'What color is that?', q_sort: 3, selected: false }
            ];

            $scope.selectedQuestions = [
                { q_id: 1, other_prop: 'yyy' },
                { q_id: 4, other_prop: 'zzz' },
            ];
        }]);
<script src="http://ift.tt/1mQ03rn"></script>
<div ng-app="MyApp" ng-controller="MyController">

        <div ng-repeat="question in allQuestions"><input type="checkbox" ng-model="x" /> </div>

    </div>

In my application the lists come from a server and I would like to be able to return the selected questions list as an object back to the server when saving the changes. I can't figure out the binding to accomplish this, or how to check the right checkboxes. Notice that the two lists are different, but bothe have the q_id value as the key to match them. Any help would be greatly appreciated.




How to pre check an angular 4 checkbox by evaluate an expression

I have an checkbox element on my component template, i need to evaluate its expression of some boolean condition to pre-check the checkbox during rendering. How can i to it?

Thanks.




ASP.NET checkboxes - does not highlight when has focus

I have a small but annoying issue in my web app. I have multiple web forms that have checkboxes. In some of them If I have focus on a checkbox you can see a little black outline around it as shown below:

enter image description here

In some places, I am able to see the black outline for all checkboxes. In other, I cannot see the black outline when have focus.

In properties window both shows as System.Web.UI.WebControls.Checkbox

I know this is a small issue, its just I'm trying to be consistent everywhere. Does anyone what could cause this?




How to use a CheckBox in Xamarin.forms?

I'm new in Xamarin.forms and I'm trying to use a multiple CheckBox that I create from a list.

I understand that CheckBox Doesn't exist in Xamarin.forms so I created a class that I finded on Internet to create the control.

When I try to create the CheckBox I can't see it. This is the code when I create the CheckBox:

if (List1 != null && List1.Count > 0)
{
    foreach (var c in List1)
    {
        CheckBox chk = new CheckBox();
        chk.CheckedChanged += Chk_CheckedChanged;
        chk.IsVisible = true;
        chk.CheckBoxBackgroundColor = Color.Blue;
        chk.TickColor = Color.Blue;
        chk.WidthRequest = 12;
        chk.HeightRequest = 12;
        StackLayoutBody.Children.Add(chk);
    }
}

And this is the code of the CheckBox.cs:

using System;
using Xamarin.Forms;

namespace TECAndroid.Services
{
    public class CheckBox : View
    {
        public static readonly BindableProperty CheckedProperty =
            BindableProperty.Create(nameof(Checked), typeof(bool), typeof(CheckBox), false, BindingMode.TwoWay,
                propertyChanged: (bindable, oldValue, newValue) =>
                {
                    ((CheckBox)bindable).CheckedChanged?.Invoke(bindable, new CheckedChangedEventArgs((bool)newValue));
                });


        public static readonly BindableProperty TickColorProperty =
            BindableProperty.Create(nameof(TickColor), typeof(Color), ypeof(CheckBox), Color.Default, BindingMode.TwoWay);

        public static readonly BindableProperty CheckBoxBackgroundColorProperty = BindableProperty.Create(nameof(CheckBoxBackgroundColor), typeof(Color), typeof(CheckBox), Color.Default, BindingMode.TwoWay);

        public EventHandler<CheckedChangedEventArgs> CheckedChanged;

        public Color TickColor
        {
            get => (Color)GetValue(TickColorProperty);
            set => SetValue(TickColorProperty, value);
        }

        public Color CheckBoxBackgroundColor
        {
            get => (Color)GetValue(CheckBoxBackgroundColorProperty);
            set => SetValue(CheckBoxBackgroundColorProperty, value);
        }

        public bool Checked
        {
            get => (bool)GetValue(CheckedProperty);
            set
            {
                if (Checked != value) SetValue(CheckedProperty, value);
            }
        }
    }

    public class CheckedChangedEventArgs : EventArgs
    {
        public CheckedChangedEventArgs(bool value)
        {
            Checked = value;
        }

        public bool Checked { get; }
    }
}

Can anyone help me please?!




Enable \ Disable selection

I have RShiny code, with which i want to disable/enable number input with checkbox. However, it works only for disable. How could i fix that?

library(shiny)
    runApp(shinyApp(
      ui = fluidPage(
        shinyjs::useShinyjs(),
        numericInput("test", "Test", 5),
        checkboxInput("submit", label="Choose")
      ),
      server = function(input, output, session) {
        observeEvent(input$submit, {
          shinyjs::disable("test")
        })
      }
    ))




On Scrolling Check Boxes are getting Unchecked or Vice versa in android RecyclerView

I have a check box in RecyclerView Adapter's View Item. When scrolling, some check boxes are getting checked and some are getting unchecked. I have taken help from this and this But I am unable to find the exact solution to this.

Here is my code

 @Override
public void onBindViewHolder(final AllContactsAdapter.ViewHolder holder, final int position) {

    phoneContactsModel = listOfContacts.get(position);
    holder.name.setText(phoneContactsModel.getContactName());
    holder.phoneNumber.setText(phoneContactsModel.getContactNumber());
    holder.checkBox.setOnCheckedChangeListener(null);
    holder.checkBox.setSelected(phoneContactsModel.isChecked());

    holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            phoneContactsModel.setChecked(b);

        }
    });

    holder.checkBox.setSelected(phoneContactsModel.isChecked());

    holder.contactLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (phoneContactsModel.isChecked()) {
                holder.checkBox.setSelected(false);
                copyOfListOfContacts.remove(listOfContacts.get(position));

            } else {
                holder.checkBox.setSelected(true);
                copyOfListOfContacts.add(listOfContacts.get(position));

            }
        }
    });
}

For example, I have checked 1,2,3 items in list. When I scrolled down and come up , then 13 is checked and 2 is unchecked along with other some items.Please help me.

Any solution is appreciated.

Thank You.




How to keep parent gridview checkbox value

CITY-STATE FILTER

I have a parent gridview. City and state. I binding City on Page_Load. If client click the plus button, i show the state gridview and choosing state with the checkbox. But, if you click the minus button and i missing the checkbox value. I hope you understand :)

protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string CityId = gridviewcity.DataKeys[e.Row.RowIndex].Value.ToString();

                string query = @"(SQL QUERY) where cityid= '" + CityId + "'";
                GridView gridviewstate = e.Row.FindControl("gridviewstate") as GridView;
                DataTable table = (DataTable)result.ReturnValue;
                gridviewstate .DataSource = table;
                gridviewstate .DataBind();

        }
    }




jeudi 28 décembre 2017

Checkboxes How can i check to sets at same time

I have 2 sets of checkboxes in my webpage, and i have a small script that is checking the boxes and not the others when i click one, Which is what i want it to do.

unfortunatly it only checks one set of the boxes. and leaves the other set unchecked..

Allthough on reloading my page. both sets are checked , but this is due to my post veriable.. i will show you the code..

can anybody see where i could update it to check both boxes on clicking one box.. thank you.

<div id='checkbox-container'>

    <input type="checkbox" id="small" name="displaytypethumbs"  value="minlist" <?php if (!empty($_POST['displaytypethumbs'])): ?> checked="checked"<?php endif; ?> onclick="chbx(this)">
    <label for="small" class="smalllistings">Thumbs</label>
    </input>

    <input type="checkbox" id="large"  name="displaytypegallery"  value="maxlist" <?php if (!empty($_POST['displaytypegallery'])): ?> checked="checked"<?php endif; ?> onclick="chbx(this)">
    <label for="large" class="largelistings" >Gallery</label>   
    </input>

    <input type="checkbox" id="fulllistings"  name="displaytypefull"  value="fulllist" <?php if (!empty($_POST['displaytypefull'])): ?> checked="checked"<?php endif; ?>onclick="chbx(this)">
    <label for="fulllistings" class="fulllistings" >Full Listing</label>    
    </input>

</div>

<div id='checkbox-container2'>

<input type="checkbox" id="small2" name="displaytypethumbs"  value="minlist"  class="smalllistingsbox" 
<?php if (!empty($_POST['displaytypethumbs'])): ?> checked="checked"<?php endif; ?> onclick="chbx(this)">
<label for="small2" class="smalllistingsmain" >Thumbs</label>
</input>


<input type="checkbox" id="large2"  name="displaytypegallery"  value="maxlist" class="largelistingsbox"  
<?php if (!empty($_POST['displaytypegallery'])): ?> checked="checked"<?php endif; ?> onclick="chbx(this)">
<label for="large2" class="largelistingsmain" >Gallery</label>  
</input>


<input type="checkbox" id="fulllistings2"  name="displaytypefull"  value="fulllist" 
<?php if (!empty($_POST['displaytypefull'])): ?> checked="checked"<?php endif; ?> onclick="chbx(this)">   
<label for="fulllistings2" class="fulllistingsmain"  >Full Listings</label> 
   </input>


</div>

</form>

<script>
function chbx(obj)
{
   var that = obj;
   if(document.getElementById(that.id).checked == true)
  {
   document.getElementById('small').checked = false;
   document.getElementById('large').checked = false;
   document.getElementById('fulllistings').checked = false;


   document.getElementById('small2').checked = false;
   document.getElementById('large2').checked = false;
   document.getElementById('fulllistings2').checked = false;      

   document.getElementById(that.id).checked = true;
  }
}

</script>




checkbox doesn't work when add a div class

I want to change the look of the checknbox, but when I add the div with class the checkbox functionality doesnt work!

 <div class="checkbox checkbox-replace color-blue">

 <input onchange="filterme()" type="checkbox" name="type" value="check">CHECK
 </div>

but if I removed the div the checkbox will work, so my question is how to make the chechbox working and use the class in the div?




On Click, set cookie and check checkbox

I have a screen with checkboxes, on click of the label a new window will be opened with text and an agree button. Once the user clicks the agree button, a cookie is set with a unique id referencing the checkbox. How do I check this checkbox based on if the cookie equals 1. Code is below

Initial checkbox:

<input type="checkbox" id="agreementChecker-0" name="agreeCheck-0" value="35" class="mandatory agreeChecker doc_35_readit">

New Window opens with text, button at bottom:

<p align="center" id="have_read_agreement" style="text-align:center;font-size:20px;"><a href="javascript:window.close()" class="btn-read">I have read this agreement and accept all terms and conditions.</a></p>

Javascript that sets the cookie:

document.cookie = "doc_35_readit=0";

$('#have_read_agreement').on('click', function(){

document.cookie = "doc_35_readit=1";

});

Now when the window is closed, not sure how to check the checkbox. Something like this maybe?

if (cookie("doc_35_readit") == "1") {
    $(".doc_35_readit").click();
}

Any help would be appreciated




Multiple checkbox values into hidden field on click

I have a couple checkboxes, on clicking each I would like their value to go into a hidden field with jQuery seperated by commas, if they are all unchecked, the hidden field value would go back to -1. Below is what I have tried.

<input type="hidden" name="agreement_ids" value="-1">

<input type="checkbox" id="agreementChecker-1" name="agreeCheck-1" value="35" class="mandatory agreeChecker">
<input type="checkbox" id="agreementChecker-2" name="agreeCheck-2" value="45" class="mandatory agreeChecker">
<input type="checkbox" id="agreementChecker-3" name="agreeCheck-3" value="52" class="mandatory agreeChecker">

$('.agreeChecker').click(function(){

        if($(this).prop('checked')){

            var resultObj = $(this).val();
            var outputObj = $('input[name="agreement_ids"]');
            var stringToAppend = resultObj.val().length > 0 ? resultObj.val() + "," : "";
        resultObj .val( stringToAppend + outputObj.val() );

        }else{
            if($('.agreement-text').length > 0){
                $('input[name="agreement_ids"]').val('-1');//uncheck
            }else{
                $('input[name="agreement_ids"]').val('');
            }
        }
    });




mercredi 27 décembre 2017

Property 'checked' does not exist on type 'HTMLElement' angular 4

i am trying to checkbox check value get from .ts file. take a Boolean variable and purpose to show and hide div using this variable but faced a problem this help to solve this and also give me the right way to do this.here is my code...

.html code

checkbox codeabcde" class="form-check-input" id="abcde" value="1"(change)="checked('abcde')"> abcde

show and hide code

*ngIf='shown'

.ts file

checked(value) {

    let get_id = document.getElementById('abcde');

    if (get_id.checked == true) {
        this.shown = true
    }
    else if (get_id.checked == false)
        this.shown = false;
}

when i run ng serve then show "Property 'checked' does not exist on type 'HTMLElement'"

advance thanks




How do I make my website cross-browser compatible?

my website is properly work in google chrome but not work in other web-browser . index page design not in proper manner. plzs give some solution fast




Binding checkbox issue in WPF MVVM

I am facing a problem in getting the value from VM for checkbox IsChecked binding value. (I'm using MVVM Light).

My issue: When checkbox IsChecked is changed, it is not firing back to my VM property that I bind to.

Below is the code.

I have a class with boolean values (in a class file).

public class Rights
{
    public bool bSales { get; set; }
    public bool bProduct { get; set; }
    public bool bZone { get; set; }
    public bool bPercentage { get; set; }
    public bool bUser { get; set; }
}

And this is the property that my checkboxes will bind to (in VM).

private Rights user_Rights;
public Rights User_Rights
{
    get { return user_Rights; }
    set { Set(ref user_Rights, value); }
}

And below is the property for my 'Select All' check box (in VM).

private bool? rights_All;
public bool? Rights_All
{
    get { return rights_All; }
    set
    {
        Set(ref rights_All, value);

        if (value == true)
        {
            User_Rights = new Rights() { bSales = true, bProduct = true, bPercentage = true, bZone = true, bUser = true };
        }
        else if(value == false)
        {
            User_Rights = new Rights() { bSales = false, bProduct = false, bPercentage = false, bZone = false, bUser = false };
        }
    }
}

And finally, below is my XAML for the binding.

<CheckBox Content="Sales PIC" IsChecked="{Binding User_Rights.bSales,Mode=TwoWay}" />
<CheckBox Content="Product" IsChecked="{Binding User_Rights.bProduct,Mode=TwoWay}" />
<CheckBox Content="Zone" IsChecked="{Binding User_Rights.bZone,Mode=TwoWay}" />
<CheckBox Content="Percentage" IsChecked="{Binding User_Rights.bPercentage}" />
<CheckBox Content="User" IsChecked="{Binding User_Rights.bUser}" />
<CheckBox Content="Select All" IsChecked="{Binding Rights_All}" />

Here is what I am doing in picture. enter image description here

Any suggestion on where did I do wrong? Thanks.




Using Checkbox and Filterable in RecycleView Android

I'm creating a project, that uses a webservice to fetch the number of departments and there names and creates dynamic checkboxs. Then I'm using filterable to filter the adapter , by checking from sharedpreferences if the checkbox is checked if not checked I try to hide it from the adapter (TicketsActivity):

for (int i=0;i<filterList.size();i++) {
    if (!getFromSP(filterList.get(i) + i)) {
       mAdapter.getFilter("Department").filter(filterList.get(i).toLowerCase());
    }
}

and afther that

if (recyclerView.getAdapter() == null) {
    mAdapter.notifyItemRangeInserted(0,ticketList.size()-1);
    recyclerView.setAdapter(mAdapter);
} else {
   recyclerView.getAdapter().notifyItemRangeInserted(0,ticketList.size()-1);
}

And in my custom Adapter (TicketsAdapter):

public Filter getFilter(final String type) {
    return new Filter() {
        @Override
        protected FilterResults performFiltering(CharSequence charSequence) {
            String charString = charSequence.toString();
            if (charString.isEmpty()) {
                ticketListFiltered = ticketList;
            } else if (type.equals("Search")) {
                List<Ticket> filteredList = new ArrayList<>();
                for (Ticket row : ticketList) {
                    if (row.getTitle().toLowerCase().contains(charSequence) || row.getDate().toLowerCase().contains(charSequence) || row.getPriority().toLowerCase().contains(charSequence)) {
                        filteredList.add(row);
                    }
                }
                ticketListFiltered = filteredList;
            } else {
                List<Ticket> filteredList;
                filteredList = ticketList;
                for (Ticket row : ticketList) {
                    if (row.getDepartment().toLowerCase().contains(charSequence)) {
                        filteredList.remove(row);
                    }
                }
                ticketListFiltered = filteredList;
            }
            FilterResults filterResults = new FilterResults();
            filterResults.values =ticketListFiltered;
            return filterResults;
        }
@Override
public int getItemCount() {
    return ticketListFiltered.size();
}

However this throws an Exception on 'int java.util.List.size()' getItemCount, if i change the filteredList.remove(row) to filteredList.add(row) it will work find,but i need to remove from the adapter rows with "unchecked" department. I can't find what i'm doing wrong. Btw this works fine with SearchView




Saving checkbox text value to an array

I've been trying to figure out a good solution all day and believe I'm getting close, but I can't figure out the final solution. What I'm trying to do is save the selected (only the selected) text values of checkboxes into an array so I can eventually save it to a database. Now I'm able to do it if I do the following:

yourArray.push($('label[for=checkbox3]').text());

However, I want to avoid using specific 'for=checkbox3' and just automatically get the text value for those selected checkboxes. Once I have it working properly I'll be saving the array content into local storage. Any help is appreciated.

HTML:

<form role="form" action="" class="margin-top-fortypx">
   <div class="checkbox checkbox-container">
      <label class="checkbox-label" for="checkbox1">
         <input type="checkbox" id="checkbox1" name="type" class="remove-bootstrap checkbox-circle margin-right checkbox-js" value="true" />
          Option #1
       </label>
    </div>

    <div class="checkbox checkbox-container">
       <label class="checkbox-label" for="checkbox2">
          <input type="checkbox" id="checkbox2" name="type" class="remove-bootstrap checkbox-circle margin-right checkbox-js" value="true" />
           Option #2
        </label>
     </div> 
  </form>

Javascript:

function jobType() {

  // Not trying to do this for the 6+ checkboxes
  // var text = $('label[for=checkbox1]').text();
  // var textt = $('label[for=checkbox2]').text();
  // var texttt = $('label[for=checkbox3]').text();
  var yourArray = [];

  $("input:checkbox[name=type]:checked").each(function() {
    yourArray.push($('label[for=checkbox3]').text());
  });

  alert(yourArray);

  localStorage.setItem('jobs-selected', text);
  var job = localStorage.getItem("jobs-selected");

}

Image of current checkbox form:

enter image description here

My goal is this: yourArray = [Option #1, Option #2, Option#4, Option #8] depending on random selection from the user.

I hope I explained it well enough for what I'm trying to do.




MS Access - Changing Query Criteria based on checkbox

I've got a Query running which works fine now. It lists all transaction done. I want to add a checkbox to the Form that uses the Query to filter out any transaction with a Cancelled Date listed on it. I've tried adding a Criteria to the CancelDate column on the query like this:

=IIf( Forms![Show DPA List]![chkShowCanc] =true,"*","IsNull")

And I keep getting a 'This Expression is typed incorrectly' error....

Is there a better way to approach this?




Checkbox check all is not working correctly

I have a form field where I have two fields one containing countries and other containing memberships and both have check boxes. The problem is that with the code I am using to Select All the countries (check/uncheck all the check boxes for countries) also checks or unchecks the memberships field. I want to differentiate between the two so that I only check countries and not the check boxes in the membership field.

Here is the code I am using:

$("#checkCountries").click(function(){
  $('input:checkbox').not(this).prop('checked', this.checked);
});

Here, input:checkbox is making the code to work on all the checkboxes in the page. I think I need to change this to make it work specifically for that particular field (countries) only. Please help.




Change font color if checkbox is checked

Problem

If the checkbox is checked the font color of the buttons are changing to blue, but if i click one of the other 2 buttons the font color is still orange. If the checkbox is unchecked after, the home button will be white instead of orange.

Code

var fontcolor = document.getElementsByClassName('color');
var cbs = document.querySelectorAll('input[type=checkbox]');
var currentActive = document.getElementsByClassName('active');
for (var i = 0; i < cbs.length; i++) {
  cbs[i].addEventListener('change', function() {
    if (this.checked) {
      fontcolor[0].style.color = "#0099ff";
      fontcolor[1].style.color = "#0099ff";
      currentActive[0].style.color = "#0099ff";
    } else {
      fontcolor[0].style.color = "#FF8000";
      fontcolor[1].style.color = "#FF8000";
      currentActive[0].style.color = "#FFF";
    }
  });
};



var tab = document.getElementById('tabs');
var tabs = tab.getElementsByClassName('tab');
for (var i = 0; i < tabs.length; i++) {
  tabs[i].addEventListener('click', function() {
    var current = document.getElementsByClassName('active');
    current[0].className = current[0].className.replace(' active', "");
    this.className += " active";
  });
};
.color {
  color: #FF8000;
  font-weight: 700;
}

.tab.active,
.tab:active {
  color: #FF8000;
}

.blue {
  color: #0099FF;
}

.tab {
  background-color: #444;
  border: none;
  color: #FFF;
  padding: 12px 36px;
}
<p>Simple <span class="color">Text</span></p>

<div class="tabs" id="tabs">
  <button type="button" id="btn1" class="tab tab-library"><span class="icon icon-menu">Library</span></button>
  <button type="button" id="btn2" class="tab tab-home active"><span class="icon icon-home"></span>Home</button>
  <button type="button" id="btn3" class="tab tab-settings"><span class="icon icon-cog"></span>Settings</button>
</div>

<p><span class="color">Text</span> because Text is cool.</p>

<label class="color-switch"><input type="checkbox" id="check"/><span class="slider round"></span> Color Switch</label>

If possible no jQuery.




Laravel-use checkbox to display data in datatables using ajax

I want to filter using checkbox, so if checkbox is checked filter data in datatables where data in coulmn "details"= checkbox value and so on

   <input type="checkbox" id="box20" value="slip" >
    <table id="users-table">
     <thead>
     <tr>
      <td>Details</td>
  <td>Description</td>
 </tr>
</thead>
</table>

ajax

  <script type="text/javascript">
    $(function() {
    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: 'student/get_datatable',
        columns : [
            {data: 'details'},
            {data: 'Description'},
        ],
    });
    });
  </script>

controller

 public function get_datatable()
  {

    return Datatables::eloquent(Orders::query())->make(true);
  }




Im gonna crazy with checkbox, sql and values

I'm having problems with my new creation. To be realistic, it's my first test with php & SQL.

I read a lot of topics here and didn't find an answer. So, I hope you can help me.

$i = 0;
$inscritos[] = $columna['ArLicencia']; // fill with a query
echo "<input type=\"hidden\" name=\"" . $inscritos[$i] . "\" value=\"0\">"; //Used for not null results
echo "<td><input type=\"checkbox\" name=\"" . $inscritos[$i] . "\" value =" . $columna['ArAsiste']; // get array

if($columna['ArAsiste'] == 1) { //get sql value. checked by default if the value is "1"
    echo " checked";
}

This created a list of checkboxes. Easy, I guess. So, on my action page, I recovered the values of "inscritos" and the value of "value". By default, gets the value of "ArAsiste" from an SQL query and works ok.

But the checkbox is getting me "0" values if checked or null if it isn't checked but didn't get me the lucky "1".

I want to fill two arrays: One with checked licenses and other with non-checked licenses to do a query to update my DB with 1 or 0 values depending on which one I checked before.

$inscritos = $_POST['listado'];

$arrayinscritos = explode(",", $inscritos);
foreach($arrayinscritos as &$valor) {

    $valor2 = $_POST[$valor];
    if($valor2 == 1) {


        $licenciasinscritas[] = $valor;

    }
    if($valor2 == 0) {

        $licenciasquenovan[] = $valor;

    }
}

"arraysinscritos" gets the "explode" value of the array "listado" get from the first page by POST, but I don't know what is going on.

Why am I not getting the "1" value when I check and submit the form?




Sorting an 2d associative array in php using radio buttons

I have to display a ordered associative array that contains some products and their quantity in three years. When I click radio buttons and it doesnt work with build-in functions such as asort or arsort. I have created two radio buttons where I can choose if I want my array to be in ASC or DESC, but when i clicked in one of it nothing happens in my tables. What can I do?

<form action="#" method="post">
<p style="color:red;">Afishoni te dhenat per pajisjet elektronike duke perzgjedhur si me poshte:</p>
<input type="checkbox"  name="viti1" value="Viti i pare"/>Viti i pare
<input type="checkbox"  name="viti2" value="Viti i dyte"/>Viti i dyte
<input type="checkbox"  name="viti3" value="Viti i trete"/>Viti i trete<br>
*Zgjidh nje ose me shume vite per te afishuar te dhenat<br><br>

Rendit te dhenat e pajisjeve ne baze te volumit te shitjeve ne rendin:<br>
<input type="radio" name="renditja" <?php if(isset($renditja) && $renditja=="rrites") {asort($pajisjet_viti1);} ?>
value="rrites"/>Rrites
<input type="radio" name="renditja" <?php if(isset($renditja) && $renditja=="zbrites") {array_multisort($pajisjet_viti1,SORT_DESC,$pajisjet_viti2,SORT_DESC,$pajisjet_viti3,SORT_DESC);} ?>
value="zbrites"/>Zbrites<br><br>

<input type="submit" name="submit" value="Kerko"/>

</form>

<?php

//krijimi i vektoreve te asociuar dy dimensionale per 3 vitet
$pajisjet_viti1 = array
  (
  array("Televizor"=>2200,"IPhone"=>1500,"Laptop"=>5000,"Kamera"=>1700, "Nintendo Wii"=>2000,"Kindle Fire"=>1500,"PSP"=>1500,"IPad"=>1700, "Mikrovale"=>3300,"Printer"=>2250,"XBox 360"=>1000,"UPS"=>300)
  );

$pajisjet_viti2 = array
    (
    array("Televizor"=>3200,"IPhone"=>1000,"Laptop"=>5500,"Kamera"=>1100,"Nintendo Wii"=>1000,"Kindle Fire"=>1400,"PSP"=>1000,"IPad"=>1650,"Mikrovale"=>3255,"Printer"=>2257,"XBox 360"=>1122,"UPS"=>700)
    );

$pajisjet_viti3 = array 
    (
    array("Televizor"=>4210,"IPhone"=>1560,"Laptop"=>5780,"Kamera"=>1962, "Nintendo Wii"=>299,"Kindle Fire"=>500,"PSP"=>1690,"IPad"=>3880, "Mikrovale"=>3320,"Printer"=>2250,"XBox 890"=>1000,"UPS"=>1000) 
    );




//per te kontrolluar nese eshte shtypur butoni kerko dhe nese eshte zgjedhur te pakten nje nga vitet
if(isset($_POST['submit'])){
    if(!isset($_POST['viti1']) && !isset($_POST['viti2']) && !isset($_POST['viti3'])){
    echo "<br><br>Zgjidh  nje ose me shume vite per te afishuar te dhenat";
    }



//per te kontrolluar nese eshte shtypur viti1 dhe per te shfaqur tabelen ne rast se ai eshte klikuar
if(isset($_POST['viti1'])){
asort($pajisjet_viti1);
echo "<table border='1' cellspacing=0 cellpadding=0>
<caption>Viti i pare</caption>
<tr>
<th>Produkti </th>
<th>Sasia</th>
</tr>";
for($r=0;$r<count($pajisjet_viti1);$r++)
{  echo "<tr>";
    foreach($pajisjet_viti1[$r] as $key=>$value)
    {
    echo "<td>".$key."</td><td>".$value."</td></tr> ";
    }   
  }
}


//per te kontrolluar nese eshte shtypur viti2 dhe per te shfaqur tabelen ne rast se ai eshte klikuar
if(isset($_POST['viti2'])){
//arsort($pajisjet_viti2);
echo "<table border='1' cellspacing=0 cellpadding=0>
<caption>Viti i dyte</caption>
<tr>
<th>Produkti </th>
<th>Sasia</th>
</tr>";
for($r=0;$r<count($pajisjet_viti2);$r++)
{  echo "<tr>";
    foreach($pajisjet_viti2[$r] as $key=>$value)
    {
    echo "<td>".$key."</td><td>".$value."</td></tr> ";
    }   
  }
}

//per te kontrolluar nese eshte shtypur viti3 dhe per te shfaqur tabelen ne rast se ai eshte klikuar
if(isset($_POST['viti3'])){

echo "<table border='1' cellspacing=0 cellpadding=0>
<caption>Viti i trete</caption>
<tr>
<th>Produkti </th>
<th>Sasia</th>
</tr>";
for($r=0;$r<count($pajisjet_viti3);$r++)
{  echo "<tr>";
    foreach($pajisjet_viti3[$r] as $key=>$value)
    {
    echo "<td>".$key."</td><td>".$value."</td></tr> ";
    }   
  }
}
}


?>

</body>
</html>




wpf bind command to checkbob in list box

i have a ListBox that host checkbox values

i want to do a command with check box but it does not bind

<ListBox Name="CategoriesListBox" ItemsSource="{Binding AllCategories}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <CheckBox IsEnabled="True" Content="{Binding Path=Name}" IsChecked="{Binding Path=IsChecked, Mode=TwoWay}" Margin="1,1,1,1"
              Command="{Binding UpdateCategoriesCommand}"/>
    </DataTemplate>
</ListBox.ItemTemplate>

i have the problem with

Command="{Binding UpdateCategoriesCommand}

any help ?




Select Values from Checked DatagridView Items in C#

I have my code as follows:

        DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
        actGrid.Columns.Add(chk);
        chk.HeaderText = "Select";
        chk.Name = "select";
        chk.ReadOnly = false;

        DataGridViewTextBoxColumn mc_no = new DataGridViewTextBoxColumn();
        actGrid.Columns.Add(mc_no);
        mc_no.HeaderText = "M/C Number";
        mc_no.Name = "mc_no";
        mc_no.Width = 200;
        mc_no.ReadOnly = true;

        DataGridViewTextBoxColumn act_name = new DataGridViewTextBoxColumn();
        actGrid.Columns.Add(act_name);
        act_name.HeaderText = "Name";
        act_name.Name = "member";
        act_name.Width = 262;
        act_name.ReadOnly = true;


        while (DR.Read())
        {
            actGrid.Rows.Add(true,DR.GetInt32(0).ToString(),DR.GetString(2) + " " + DR.GetString(1));

        }

Which produces the following output:

DataGrid

And now i want to perform some actions based on which accounts were selected(by toogling the trailing checkboxes), esp M/C Number.




Laravel insert multiple checkbox values into the database

I am trying to insert multiple values from multiple values checkbox also adding the dropmenus values i need a way to post all these values this the view code:

@extends('admin/main')
@section('title','|Add Section')
@section ('content')
{!!Form::open()!!}

<br>


<br>

<br>


<br>

<br>



<br>
<br>
    <div class="col-md-8" id="courses">
                <h3 align="center">Computer Engineering courses</h3>
                <br>
                <form>
                @foreach ($courses as $course)
                 <div class="form-check">
                    <label>
                        <input type="checkbox" name="sections[]" value=""> <span class="label-text"><span style="color:#ea9c9b"></span>  </span>
                    </label>
                </div>
                @endforeach

<form>          


{!!Form::close()!!}
        </div>




Jquery checkbox prop method with change event

I need do some actions with checkboxes which was checked from another checkbox. But it's doesn't work. Why? Simple example:

$('.tmp').click(function(){
  $('.quest:not(:checked)').prop('checked', true);  
});

$('.quest').change(function(){
  console.log(this);
});
<script src="http://ift.tt/1oMJErh"></script>
<input type="checkbox" name="" id="" class="tmp"> Click me to see some magic... or not(
<br>

<input type="checkbox" name="" id="" class="quest">1
<input type="checkbox" name="" id="" class="quest">2
<input type="checkbox" name="" id="" class="quest">3
<input type="checkbox" name="" id="" class="quest">4
<input type="checkbox" name="" id="" class="quest">5
<input type="checkbox" name="" id="" class="quest">6
<input type="checkbox" name="" id="" class="quest">7
<input type="checkbox" name="" id="" class="quest">8
<input type="checkbox" name="" id="" class="quest">9
<input type="checkbox" name="" id="" class="quest">10



mardi 26 décembre 2017

Laravel - show data in datatables with checkbox and ajax

I want the data to appear in the datatable when the checkbox is checked, by the value of the checkbox , if the value is credit that shows all rows containing a credit in the column name details and so on

view:

 <input type="checkbox" id="credit" value="credit" >
 <table id="users-table">
 <thead>
<tr>
  <td>Details</td>
  <td>Date</td>
  <td>Description</td>
 </tr>
</thead>
</table>

ajax

  <script type="text/javascript">
    $(function() {
    $('#users-table').DataTable({
        processing: true,
        serverSide: true,
        ajax: 'student/get_datatable',
        columns : [
            {data: 'details'},
            {data: 'Date'},
            {data: 'Description'},
        ],
        pageLength: 5,
    });
    });
  </script>

controller

 public function get_datatable()
  {

    return Datatables::eloquent(Checks::query())->make(true);
  }




Clearing a line plotted by uitable logical cell in Matlab Guide

I have created a table in Matlab GUIDE which has logical cells(checkboxes) in the first column. A name of a signal is stored in the second column. The code below is used to plot and delete the selected signals.

% --- Executes when entered data in editable cell(s) in uitable4.
function uitable4_CellEditCallback(hObject, eventdata, handles)
data = get(handles.uitable4, 'Data');
x = handles.x;
signalPlot = handles.signalPlot;

currentRow = eventdata.Indices(1);
if eventdata.PreviousData == 0
    signalCell = data(currentRow, 2);
    signalName = signalCell{1};
    signal = evalin('base', signalName);
    axes(handles.axes2);
    hold on;
    signalPlot(currentRow) = plot(x, signal);
    hold off;
    handles.plotThis = signalPlot;
    guidata(hObject, handles);
end
if eventdata.PreviousData == 1;
   signalPlot = handles.plotThis;
   delete(signalPlot(currentRow)); 
end

This is the problematic case: When I choose 3 cellboxes, e.g. first, second and third rows. And attempt to delete the first one. I get an error:

Error using delete
Cannot access method 'delete' in class
'matlab.ui.Root'.

What can I do to achieve what I want? Thank you very much from now on.




WPF Storyboard animation unintended shaking

I'm trying to create an animated checkbox in WPF, similar to this one.

This question is NOT a duplicate of this one, because there is no problem with the framerate of the animation.

The animations and the storyboards are already in place, and working properly, but for some rason, while the animation is playing, it looks like the whole thing is shaking, as demonstrated here. The effect is best seen on the right border of the box.

The following is the XAML source code of the custom checkbox. I don't think that there is a need to post the code behind, since it doesn't contain anything other than the RoutedEvent definitions (FlatCheckBox.Checked and FlatCheckBox.Unchecked).

<UserControl x:Name="userControl" x:Class="Sync_Launcher.Controls.FlatCheckBox"
         xmlns="http://ift.tt/o66D3f"
         xmlns:x="http://ift.tt/mPTqtT"
         xmlns:mc="http://ift.tt/pzd6Lm" 
         xmlns:d="http://ift.tt/pHvyf2"
         xmlns:controls="clr-namespace:Sync_Launcher.Controls"
         mc:Ignorable="d" 
         d:DesignHeight="30"
         Background="Transparent" MouseLeftButtonDown="FlatCheckBox_OnMouseLeftButtonDown">
<Grid SnapsToDevicePixels="True">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="{Binding ActualHeight, ElementName=userControl}"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid Column="0">
        <Grid Name="tickHolderGridRoot" Margin="4">
            <Grid.LayoutTransform>
                <TransformGroup>
                    <RotateTransform x:Name="rotationTransform" Angle="0"/>
                </TransformGroup>
            </Grid.LayoutTransform>
            <Grid Name="tickHolderGrid" Margin="0,0">
                <Border Name="tickBorder" SnapsToDevicePixels="True" Opacity="0" BorderThickness="2,0,0,2" BorderBrush="#FF1CA36F" />
                <Border Name="overlayBorder" SnapsToDevicePixels="True" Opacity="1" BorderThickness="2,2,2,2" BorderBrush="#FF404D61" />
            </Grid>
        </Grid>
    </Grid>
    <Label 
        Grid.Column="1" 
        Content="{Binding Text, ElementName=userControl}" 
        VerticalContentAlignment="Center" 
        FontSize="16" 
        Padding="5,0" 
        FontStyle="{Binding FontStyle, ElementName=userControl}" 
        FontWeight="{Binding FontWeight, ElementName=userControl}"/>
</Grid>
<UserControl.Resources>
    <Duration x:Key="animationDuration">0:0:0.4</Duration>
    <KeyTime x:Key="animationEnd">0:0:0.4</KeyTime>
</UserControl.Resources>
<UserControl.Triggers>
    <EventTrigger SourceName="userControl" RoutedEvent="controls:FlatCheckBox.Checked">
        <BeginStoryboard>
            <Storyboard Timeline.DesiredFrameRate="60">
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="rotationTransform" Storyboard.TargetProperty="Angle" Duration="{StaticResource animationDuration}">
                    <EasingDoubleKeyFrame KeyTime="0" Value="0"/>
                    <EasingDoubleKeyFrame KeyTime="{StaticResource animationEnd}" Value="-60">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <CircleEase EasingMode="EaseOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimation Storyboard.TargetName="overlayBorder" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="{StaticResource animationDuration}"/>
                <DoubleAnimation Storyboard.TargetName="tickBorder" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="{StaticResource animationDuration}"/>
                <ThicknessAnimation Storyboard.TargetName="tickHolderGrid" Storyboard.TargetProperty="Margin" From="0,0" To="0,2" Duration="{StaticResource animationDuration}"/>
                <ThicknessAnimation Storyboard.TargetName="tickHolderGridRoot" Storyboard.TargetProperty="Margin" From="4" To="2,0,2,4" Duration="{StaticResource animationDuration}"/>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
    <EventTrigger SourceName="userControl" RoutedEvent="controls:FlatCheckBox.Unchecked">
        <BeginStoryboard>
            <Storyboard>
                <DoubleAnimationUsingKeyFrames Storyboard.TargetName="rotationTransform" Storyboard.TargetProperty="Angle" Duration="{StaticResource animationDuration}">
                    <EasingDoubleKeyFrame KeyTime="0" Value="-60"/>
                    <EasingDoubleKeyFrame KeyTime="{StaticResource animationEnd}" Value="0">
                        <EasingDoubleKeyFrame.EasingFunction>
                            <CircleEase EasingMode="EaseOut"/>
                        </EasingDoubleKeyFrame.EasingFunction>
                    </EasingDoubleKeyFrame>
                </DoubleAnimationUsingKeyFrames>
                <DoubleAnimation Storyboard.TargetName="overlayBorder" Storyboard.TargetProperty="Opacity" From="0" To="1" Duration="{StaticResource animationDuration}"/>
                <DoubleAnimation Storyboard.TargetName="tickBorder" Storyboard.TargetProperty="Opacity" From="1" To="0" Duration="{StaticResource animationDuration}"/>
                <ThicknessAnimation Storyboard.TargetName="tickHolderGrid" Storyboard.TargetProperty="Margin" From="0,2" To="0,0" Duration="{StaticResource animationDuration}"/>
                <ThicknessAnimation Storyboard.TargetName="tickHolderGridRoot" Storyboard.TargetProperty="Margin" From="2" To="4" Duration="{StaticResource animationDuration}"/>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger>
</UserControl.Triggers>

I have tried increasing the storyboard framerate by settings the Timeline.DesiredFrameRate to 60, as you can see in the code, but it had no effect on the shakyness of the animation.

I have also tried setting the SnapsToDevicePixels property to true hoping that it would improve the animation.

What might be the cause of this shaking effect, what can I do to eliminate it?




Change thickness of checkbox

I am using custom AppCompatCheckBox, but i need to change the thickness and color border of the checkbox, which should look like this :

enter image description here




lundi 25 décembre 2017

Using jquery check/uncheck SelectAll checkbox when all the checkboxes in the group are checked/unchecked

I need SelectAll checkbox should be checked when all the li's in the group checkboxes are checked.

Here I am having two checkbox groups. I need optimized code. try to work two ID's combindly?

Note: If all li's are checked/unchecked other group should not be affected and vice-versa.

Please have a look at my work till now

    <ul>
            <li><input type="checkbox" id="one_select_all"/> Group ONE Selecct All</li>
            <li><input class="one_checkbox" type="checkbox" name="check[]"> This is Item 1</li>
            <li><input class="one_checkbox" type="checkbox" name="check[]"> This is Item 2</li>
            <li><input class="one_checkbox" type="checkbox" name="check[]"> This is Item 3</li>
            <li><input class="one_checkbox" type="checkbox" name="check[]"> This is Item 4</li>
            <li><input class="one_checkbox" type="checkbox" name="check[]"> This is Item 5</li>
            <li><input class="one_checkbox" type="checkbox" name="check[]"> This is Item 6</li>
    </ul>
    <ul>
            <li><input type="checkbox" id="two_select_all"/> Group TWO Selecct All</li>
            <li><input class="two_checkbox" type="checkbox" name="check[]"> This is Item 1</li>
            <li><input class="two_checkbox" type="checkbox" name="check[]"> This is Item 2</li>
            <li><input class="two_checkbox" type="checkbox" name="check[]"> This is Item 3</li>
            <li><input class="two_checkbox" type="checkbox" name="check[]"> This is Item 4</li>
            <li><input class="two_checkbox" type="checkbox" name="check[]"> This is Item 5</li>
            <li><input class="two_checkbox" type="checkbox" name="check[]"> This is Item 6</li>
   </ul>     


        <script>
        $("#one_select_all").change(function(){
            $(".one_checkbox").prop('checked', $(this).prop("checked"));
        });
        $("#two_select_all").change(function(){
            $(".two_checkbox").prop('checked', $(this).prop("checked")); 
        });
        $('.one_checkbox , .two_checkbox').change(function(){ 
            if(false == $(this).prop("checked")){ 
                $("#one_select_all").prop('checked', false);
            }else{
            $("#one_select_all").prop('checked', true);
            }
            if ($('.one_checkbox:checked, .two_checkbox:checked').length == $('.one_checkbox, .two_checkbox').length ){
                $("#one_select_all, #two_select_all").prop('checked', true);
            }else{
             $("#one_select_all, #two_select_all").prop('checked', false);
            }
        });
        </script>




limit selectable checkboxes in an array, (max 1 per column, 10 per row, 15 total) based on three php variables

I have an array of checkboxes generated with php. I can not display every checkbox because of previous choices by other users.

for($i=0;$i<$maxrows;$i++)
{
   $already_selected[$i]=0; 
   for($a=0;$a<$maxcols;$a++)
   {
      $value=$mat[$i][$a];
      if($value>0)
      {
         echo"<input type='checkbox' name='arr[$i][$a]' value='$uid'/>";
      }  
      else
      {
         echo"<input type='hidden' name='arr[$i][$a]' value='$value'/>";
         $already_selected[$i]+=1; 
      }
   }   
}

I have to limit the selectable checkboxes in a (for me, at least) complex way: The user must be able to choose: - One checkbox for each column maximum - Maximum $x checkboxes per row (where x is calculated by php as: $maximum_per_row - $already_selected) - Maximum $y checkboxes over the entire grid (where y is a php variable received by the previous page).

Is it possible?

Maybe something like:

echo"
      <script type='text/javascript'>
          var limit = $y;
          $('input.ggrid').on('change', function(evt)
          {
            if($('input[class='ggrid']:checked').length >= limit)
            {
              this.checked = false;
            }
          });
      </script>
";
for($i=0;$i<$maxrows;$i++)
{
   echo"
      <script type='text/javascript'>
          var limit = $maximum_per_row[$i] - $already_selected[$i];
          $('input.row$i').on('change', function(evt)
          {
            if($('input[class='row$i']:checked').length >= limit)
            {
              this.checked = false;
            }
          });
      </script>
   "; 
   for($a=0;$a<$maxcols;$a++)
   {
      echo"
      <script type='text/javascript'>
          var limit = 1;
          $('input.col$a').on('change', function(evt)
          {
            if($('input[class='col$a']:checked').length >= limit)
            {
              this.checked = false;
            }
          });
      </script>
      ";
   }   
}
for($i=0;$i<$maxrows;$i++)
{
   $already_selected=0; 
   for($a=0;$a<$maxcols;$a++)
   {
      $value=$mat[$i][$a];
      if($value>0)
      {
         echo"<input type='checkbox' class='col$a row$i ggrid'name='arr[$i][$a]' value='$uid'/>";
      }  
      else
      {
         echo"<input type='hidden' name='arr[$i][$a]' value='$value'/>";
         $already_selected+=1; 
      }
   }   
}

which obviously does not work... Thank you in advance!




How to check or uncheck a checkboxlist item according to database values

In my application, the user can choose different options from a data table, according to the company's interest. So a checkboxlist is populated from a stored procedure called SEL_Dewey_Subcat_Raw, that prints the ID value and the name to the checkbox list. This is ok, and it's working fine.

But now I need the user to be able to edit what they choose before. So I need that the checkboxlist is populated according to what they've chosen before, If the category was chosen before that particular item must be selected.

The code that populates the CBL:

SELECT * FROM [dbo].[Dewey_Subcat] ORDER BY[dbo].[Dewey_Subcat].[Nombre] ASC

This info is stored in a data table called [dbo].[Proveedores_Dewey], and it has this columns:

  1. ID (PK int)
  2. Id_Proveedor (int), the ID of the client
  3. Id_Dewey_Subcat (int), the ID of the category

So if one checkbox item is selected, for example, the data stored will be:

ID: 1 Id_Proveedor: 24 (client's ID) Id_Dewey_Subcat: 38 (category's)

This is the code I have so far for the edit panel checkboxlist, but it's not working!

For Each li As ListItem In Dewey_RBL.Items
        Dim SqlConDeweyCBL As SqlConnection
        Dim SqlComDeweyCBL As SqlCommand
        Dim SqlDRDeweyCBL As SqlDataReader
        SqlConDeweyCBL = New SqlConnection(ConfigurationManager.ConnectionStrings("EnchufeBBMCA").ToString())
        SqlComDeweyCBL = New SqlCommand("SELECT [dbo].[Proveedores_Dewey].[Id_Dewey_Subcat] FROM [dbo].[Proveedores_Dewey] WHERE([dbo].[Proveedores_Dewey].[IdProveedor] = '" & empresaId & "')", SqlConDeweyCBL)
        If SqlConDeweyCBL.State = ConnectionState.Closed Then
            SqlConDeweyCBL.Open()
        End If
        SqlDRDeweyCBL = SqlComDeweyCBL.ExecuteReader()
        While SqlDRDeweyCBL.Read()

            If SqlDRDeweyCBL("Id_Dewey_Subcat") = li.Value Then

                li.Selected = True
            Else

                li.Selected = False
            End If

        End While
        SqlDRDeweyCBL.Close()
        SqlConDeweyCBL.Close()
    Next

So how can I check the items of the checkbox list that are stored in the [dbo].[Proveedores_Dewey] and leave the others unchecked?

Thanks!




wxWidgets Python save checkbox and other elements values in a text

How to save (and restore) the values of the graphical elements of the wxWidgets in Python? I want some more friendly way, maybe using a for to scrape all the elements and save the current value in a txt when I close the window and restore when I load the app. I do not want to typing 2 line of code (save and restore) to each new element that I add.




Get Checked Nodes in a jsTree When Checking/Unchecking Parent Nodes

Note: I have already read the following threads:

I have a multilevel jstree with multiple sibling parent nodes and several children under each parent node.

Whenever any node gets checked/unchecked, I want to receive the list of all checked nodes. I did this using the following method:

$("#jstree-picker").on("check_node.jstree uncheck_node.jstree", function (event, data) {
    console.log(data.selected);
});

When I check/uncheck any of the leaf nodes (lowest-level children), the above code prints out the list of all selected nodes correctly. However, when I check/uncheck a parent node, all its children get checked/unchecked correctly, but they do not show up in the list of selected nodes!




Filter results based on checkboxes in Angular

I want to have a filter based on active-states from available checkboxes.

First everything should gets displayed, after a filter is selected, in this case an ability, it should only display objects which contains atleast the ability.

My intitial thought process was like that: Create an array which consists of all results and also have an array which consists of the filtered results. Then after a checkbox gets unchecked just show the complete array again. However that doesn't work because sometimes if the complete array is shown again it shows too much results because some checkboxes are still active.

Stackblitz: http://ift.tt/2DbmSEB

App Component:

import { Component, OnInit } from '@angular/core';

interface Hero {
  name: string;
  powers: string[];
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html'
})
export class AppComponent {

  fullHeroes: Hero[] = [];
  heroes: Hero[] = [];
  powers = new Set<String>();

  constructor() {
    this.heroes.push(
      {
        name: 'Goku',
        powers: ['Strength', 'Speed', 'Teleportation', 'Plot-Armor']
      },
      {
        name: 'Vegeta',
        powers: ['Strength', 'Speed', 'Teleportation']
      },
      {
        name: 'Mr.Satan',
        powers: ['Coolness']
      },
      {
        name: 'A Nobody',
        powers: []
      }
    );

    this.heroes.forEach(h => {
      h.powers.forEach(power => this.powers.add(power));
    });

    this.fullHeroes = this.heroes.slice(0);

  }


  filter(type, name, checked) {
    console.log(type); // type of filter (here power)
    console.log(name); // name of the power
    console.log(checked);

    switch (type) {
      case 'power': {
        if (checked) {
          const returnArray = [];
          for (let i = 0; i < this.heroes.length; i++) {
            const currentHero = this.heroes[i];
            if (currentHero) {
              for (let j = 0; j < currentHero.powers.length; j++) {
                if (currentHero.powers[j] === name) {
                  returnArray.push(currentHero);
                }
              }
            }
          }
          this.heroes = returnArray;
          console.log('this.fullHeroes');
          console.log(this.fullHeroes);
        } else {
          this.heroes = JSON.parse(JSON.stringify(this.fullHeroes));
          // here another loop to check which values should still be removed!
        }
        return;
      }
    }
  }

}

App.Component.html

<div class="container">
  <h1>World of Heroes</h1>
  <p>Filter your Heroes based on some criteria!</p>

  <div class="filter">
    <form #heroForm="ngForm">

      <fieldset>
        <legend>Choose the powers</legend>
        <div class="form-check" *ngFor="let power of powers">
          <label class="form-check-label">
              <input  class="form-check-input" 
              type="checkbox" 
              [name]="power" 
              (change)="filter('power', $event.target.name, $event.target.checked)"> 
            </label>
        </div>

      </fieldset>
    </form>
  </div>

  <hr>
<h2>Results:</h2>

  <div class="row result-list">

    <div class="col-md-4 hero" *ngFor="let hero of heroes">
      <h3>Name: </h3>
      Powers:
      <ul>
        <li *ngFor="let power of hero.powers"></li>
      </ul>
    </div>

  </div>

</div>




ngModel checks my checkboxes?

I'm using a form with hundreds of checkboxes for my shop search engine. Everything works smoothly, except that ngModel seems that checks all of my checkboxes. Why is that? I don't see checked anywhere in the Elements tab in my browser...

HTML:

<form #filterForm="ngForm" *ngIf="properties">
    <fieldset ngModelGroup="inputs" #inputs="ngModelGroup">
        <button type="button" class="btn btn-primary" style="width: 100%;" (click)="toggleTab('filters')">Филтриране на резултатите</button>
        <div id="filters" style="display: none;">
            <hr />
            <div class="row">
                <div class="col-sm-6" *ngFor="let property of properties.SearchPropertyInfoList.Content.Item">
                    <h5></h5>
                    <div class="filter">
                        <label class="custom-control custom-checkbox" *ngFor="let value of property.Values.PropertyValue">
                        <input type="checkbox" name="" 
                                [ngModel]="property.Id + '-' + value.Id" class="custom-control-input" />
                        <span class="custom-control-indicator"></span>
                        <span class="custom-control-description"></span></label>
                    </div>
                </div>
            </div>
            <hr />
            <button type="button" class="btn btn-primary" style="width: 100%;" (click)="searchBy(filterForm)">Запази филтрите</button>
        </div>
    </fieldset>
</form>

JS:

searchBy(filterForm) {
    console.log(filterForm.form.value.inputs);
}


EDIT:

Also, how can I join the values of the inputs as a comma-separated string? They should become: 1627207-3232483,1627207-3232484.... I've tried with filterForm.form.value.inputs.join(), but it gives join is not a function error.

{"1627207-3232483":"1627207-3232483","1627207-3232484":"1627207-3232484","1627207-3232481":"1627207-3232481"}




Map Enum to user choice checkboxes

At present I have the following

if ((int)dpRepeatType.SelectedValue == (int)Constants.RepeatType.Weekly)
{
                 wrule = new WeeklyRecurrenceRule(Convert.ToDateTime(dtDateStart.Value),WeekDays.Monday, 1);
                _newAppointment.RecurrenceRule = wrule.ToString();

}

On Screen I have 7 checkboxes representing the days of the week. Sunday to Sat My question is WeekDay is an internal enum of telerik rad scheduler based on the following.

My Question is insteads of doing a tone of if statements on individual checkboxes to see which the user can select how can i do this with linq at present I am doing it with if statements but I am sure there a better way.

[Flags]
    public enum WeekDays
    {
        //
        // Summary:
        //     Specifies none of the days
        None = 0,
        //
        // Summary:
        //     Specifies the first day of the week
        Sunday = 1,
        //
        // Summary:
        //     Specifies the second day of the week
        Monday = 2,
        //
        // Summary:
        //     Specifies the third day of the week
        Tuesday = 4,
        //
        // Summary:
        //     Specifies the fourth day of the week
        Wednesday = 8,
        //
        // Summary:
        //     Specifies the fifth of the week
        Thursday = 16,
        //
        // Summary:
        //     Specifies the sixth of the week
        Friday = 32,
        //
        // Summary:
        //     Specifies the work days of the week
        WorkDays = 62,
        //
        // Summary:
        //     Specifies the seventh of the week
        Saturday = 64,
        //
        // Summary:
        //     Specifies the weekend days of the week
        WeekendDays = 65,
        //
        // Summary:
        //     Specifies every day of the week
        EveryDay = 127
    }
}

This is what the ui is like to what I am trying to achieve.

enter image description here




dimanche 24 décembre 2017

how to checked only one in one row checkbox using javascript

how to checked only one in one row checkbox using javascript

here is my view

<?php $c=0; for($a=0; $a < 5; $a++) { ?>
<table>
<tr class="cbclass">
<td><input type="checkbox" name="cbname" value="1" id="cb" class="cb"></td>
<td><input type="text" name="f_nilai1[]" id="id_tnilai<?php echo $c++; ?>" ></td>

<td><input type="checkbox" name="cbname" value="1" id="cb" class="cb"></td>
<td><input type="text" name="f_nilai2[]" id="id_tnilai<?php echo $c++; ?>" ></td>

<td><input type="checkbox" name="cbname" value="1" id="cb" class="cb"></td>
<td><input type="text" name="f_nilai3[]" id="id_tnilai<?php echo $c++; ?>"></td>

<td><input type="checkbox" name="cbname" value="1" id="cb" class="cb"></td>
<td><input type="text" name="f_nilai4[]" id="id_tnilai<?php echo $c++; ?>"></td>

<td><input type="checkbox" name="cbname" value="1" id="cb" class="cb"></td>
<td><input type="text" name="f_nilai5[]" id="id_tnilai<?php echo $c++; ?>"></td>
</tr>

this is my javascript i have already change value in input text when ckeckbox is clicked, i use it because in insert_batch checkbox not post when null so i use input text to post it, and its running well. next is i want only checked in one row, can anybody help me??

<script type="text/javascript">
$(document).ready(function() 
{
var a = $(".cb").length;                                                                                
  $(".cb").click(function(event)
  {
    for(var i=0; i<a; i++) {
        var check = document.getElementsByName('cbname');
            if(check[i].checked) 
        {
                $("#id_tnilai"+[i]).val(1);
                } else {
                $("#id_tnilai"+[i]).val(0);
                }
        }
                                                                                                                                                                                
   });
});
</script>



laravel return datatable rows if checkbox is checked

How can I display data if checkbox checked, as example if checkbox which has value (CHECK) is checked then display only rows where the column details has the title CHECK also if checkbox of CREDIT checked then return data of rows where the details cloumn has the two value CHECK and credit. Hope there is away to make this using ajax blade:

   </div><label>CHECK</label> 
   <input type="checkbox" id="chk-20" >
   </div><label>CREDIT</label> 
    <input type="checkbox" id="chk-21" >

     <script type="text/javascript">
     $(function() {
    $('#users-table').DataTable({
    processing: true,
    serverSide: true,
          ajax: 'get_datatable',
    columns : [
          {data: 'details', name: 'details'},
          {data: 'postingdate', name: 'postingdate'},
          {data: 'description', name: 'description'},
           {data: 'amount', name: 'amount'},
          {data: 'type', name: 'type'},
          {data: 'slip', name: 'slip'},
           {data: 'vendor_id', name: 'vendor_id'},
          {data: 'category_id', name: 'category_id'},
        ],
        pageLength: 10,
      });
       });
    </script>

controller

  public function get_datatable()
{ 
 $users=Checks::select(['details','postingdate','description','amount','type','slip','vendor_id','category_id']);
return Datatables::of($users)->editColumn('postingdate', function ($user) 
{

return date('Y/d/m', strtotime($user->postingdate) );
})->make(true);

}




How to get alert when checkboxes in the table are not clicked and try to submit form

I am trying to send checkbox values to other page to delete the selected rows with checkbox but when there is no checkbox clicked and try to send it should give alert for checkbox is empty and if the form is submitting after the checkbox is clicked then it should give alert whether to proceed or not this is my form

<form action="deleteselectedhr" name="deleteFiles" method="post" onsubmit="checkForm()">    
<table id="mytable" border=3 >
 <c:forEach items="${users}" var="user">
 <tr>
   <td>
     <input type="checkbox" id="saif" name="<c:out value="${user.hrid}" />" 
      value="<c:out value="${user.hrid}" />" />
   </td>  
</tr>
 </c:forEach>
</table>
<input TYPE="SUBMIT" value="Delete Selected HRs"/>
</form>
Javascript:
  <script type="text/javascript">
function checkForm(){

    var checkt = document.getElementsById('saif');
    var chekSelect = false;
    for (var i = 0; i < checkt.length; i++) {
        var myElement = checkt[i];
        if (myElement.type === "checkbox" && myElement.checked) {
            if (myElement.checked) {
                chekSelect = true;
                break;
            }
        }
    }
    if(!chekSelect) {
        alert('Please Check Atleast one record to print cheque!!!');
        return false;
    } else {
        return true;
    }
}
</script>`




samedi 23 décembre 2017

How can i make "checkboxes" that increase their number at each left click and decrease at right click?

I'm currently using a form with imaged checkboxes :

<form action="submit.php" method="POST">  
<table cellspacing="15">
<tr>
<td>
  <label for="lightning"><img src="units/lightning.png"/></label>
  <input type="checkbox" name="lightning" id="lightning">
</td>
<td>
  <label for="delita"><img src="units/delita.png"/></label>
  <input type="checkbox" name="delita" id="delita">
</td>
<td>

(it goes further down for a while, didn't paste everything)

it's a basic checkbox, but what i want is something that stacks numbers the more you click. For exemple, let's say i click once on the checkbox with my left click : it will check it and a "1" will appear above. If two times, a 2 etc...and with the right click it would decrease that said number. Is it possible in any form?

Thank you for your time.




Defining a checkbox in Android Studio

I'm new coding and have started an online course for android basics. I've been trying to add a checkbox and I can't define it in the main code, only inside one of my methods - I was just wondering why that is. Thanks very much in advance!!

//Displays the message
private void displayMessage(String message) {
    TextView orderSummaryTexView = (TextView) findViewById(R.id.order_summary_text_view);
    orderSummaryTexView.setText(message);
}

//Calculates the price
private int calculatePrice() {
    int price = 5;
    return (price * quantity);



//Prepares the final message for printing
    private String createOrderSummary(int cost, boolean cream) {
    String genMessage = ("\nQuantity: " + quantity + "\n Has Cream: " + cream + "\nTotal: " + cost + "$ \nThank you!" );
    return (genMessage);
}

//Prints out the final result
  public void submitOrder(View view) {
    CheckBox CreamCheckBox = (CheckBox) findViewById(R.id.Cream);
    boolean creamy = CreamCheckBox.isChecked();
    int price = calculatePrice();
    displayMessage(createOrderSummary(price, creamy));
}

Unless I defined the CheckBox inside my SubmitOrder method - the app would crash.




Checkbox-Trick not working

I want to use the checkbox-trick to show my mobile navbar. Somehow the h1 isn't showin up even when the invisible checkbox is checked. What have I done wrong?

#label {
  margin-left: auto;
  margin-right: auto;
  color: #000000;
  font-size: 35px;
  cursor: pointer;
  width: 47px;
}


h1 {
display: none
}
#toggle {
  display: none;
}


#toggle:checked + h1 {
                display: block;
}
  
<div id="hamburgermenu">
  <label id="label" for="toggle">&#9776;</label>
  <input id="toggle" type="checkbox">
</div>

<h1>DEMO ELEMENT</h1>



Show data from db into checkbox

I've a SQL Database with only one table for my checkbox : name(string) and value(boolean). At this time, I show a list of checkbox for test, but it's not from my db.

  public class Model{
    String name;
    int value; /* 0 -&gt; checkbox disable, 1 -&gt; checkbox enable */

    Model(String name, int value){
        this.name = name;
        this.value = value;
    }
    public String getName(){
        return this.name;
    }
    public int getValue(){
        return this.value;
    }

}

   // MainActivity 

    ListView lv;
    Model[] modelItems;
    lv = (ListView) findViewById(R.id.listView1);
        modelItems = new Model[5];
        modelItems[0] = new Model("pizza", 0);
        modelItems[1] = new Model("burger", 1);
        modelItems[2] = new Model("olives", 1);
        modelItems[3] = new Model("orange", 0);
        modelItems[4] = new Model("tomato", 1);
 //Custom Adapter is a Java Class for Show ListView with Checkbox
        CustomAdapter adapter = new CustomAdapter(this, modelItems);
        lv.setAdapter(adapter);




Getting all selected rows with DataTables checkbox plugin with server side

I have this DataTable defenition:

  var availableFilesTable = $("#availableFiles").DataTable({
                'processing': true,
                'serverSide': true,              
                'ajax': '@Url.Action("GetAllBinariesExclude", "Program", new {programId = Model.Id})',
                'columns': [
                    {
                        data: 'Id',
                        'checkboxes': {
                            'selectRow': true
                        }
                    },
                    {
                        'data': 'BinaryName'
                    },
                    { 'data': 'Sha1Hash' }
                ],
                'select': {
                    'style': 'multi'
                },
                'order': [[1, 'asc']]
            });

I want to get all the selected rows and submit them to server, I have the following code for form submit event:

  $('form').submit(function(event) {
                event.preventDefault();

                var form = this;

                var existingFileIds = selectedFilesTable.column(0).checkboxes.selected();

                var fileIndex = 0;

                var newFiles = availableFilesTable.column(0).checkboxes.selected();

                $.each(newFiles,
                    function(index, fileId) {
                        $(form).append(
                            $('<input>')
                            .attr('type', 'hidden')
                            .attr('name', 'SelectedBinaryFilesIds[' + fileIndex + ']')
                            .val(fileId)
                        );
                        fileIndex++;
                    });

                if ($(form).valid()) {
                    form.submit();
                }
            });

The problem is that when I put a debugger and inspect the content of newFiles it only contains the content of active page of DataTable, Any hint on what am I doing wrong? I want to get all the selected rows in all pages with server side rendering but with the following code I only get the selected rows in the active page.

any help is much appreciated.




Checkbox will not fire function onLoad of page

I've been banging my head on this issue for 8 hours straight and I can't figure it out.

Environment: I'm developing a webapp which has a button/switch that toggles a checkbox when clicked/checked. When the checkbox is checked, it fires a function that calls a PHP script. When UNchecked, it pauses the PHP script. This is all working great.

ISSUE: I also have the checkbox configured to be in a checked state when the page loads, thus triggering the function automatically when the page loads. However, right now, when I load the page the checkbox IS checked, but the function DOES not fire automatically UNTIL the checkbox is toggled manually.

I've used A LOT of different variables and solutions, but I can't figure it out. I'm assuming it has something to do with the "Label" class?

What am I doing wrong?

Example: You can ignore the PHP stuff, as I put in an alert for testing. YOu'll the checkbox is checked onload, but the alert does not fire onload but will fire when the checkbox is manually checked.

JSfiddle

<script>
  var nIntervId;
  var onload;

  function statusCheck() {

    $("#statusloop").load('assets/php/loop.php');
    $("#stats").load('assets/php/systembadges.php');

  };

  $(document).ready(function() {

    $(":checkbox").change(function() {
      if ($(this).is(':checked')) {
        nIntervId = setInterval(statusCheck, 3000);
        alert("checked");
      } else {
        clearInterval(nIntervId);
        alert("NOTchecked");
      }
    });
  });

</script>

<body onload="statusCheck()">

  <label class="switch" id="buttonStart">
    <input type="checkbox">
    <span class="slider round"></span>
  </label>

  <script>
    $('#buttonStart :checkbox').attr('checked', 'checked');
  </script>

</body>




Mutiple checkbox in php html

I have a form code html like this, but it's error for checkbox question, someone plase help my problem.

if(empty($tampil_pertanyaan)){
                echo "<tr><td colspan=\"6\">Data tidak tersedia</td></tr>";
    }else{
       $no = 1; //for question
       $no2 = 0; //for array
    foreach($tampil_pertanyaan as $row)
   {
    <tr>
        <td><input type="checkbox" class="w3-check" name="ket_jawaban[<?php echo $no2;?>]"  id="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil1;?>"  oninput="this.className = ''"></td>
        <td> <?php echo $row->pil1;?></td>
    </tr>
    <tr>
        <td><input type="checkbox" class="w3-check" name="ket_jawaban[<?php echo $no2;?>]"  id="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil2;?>" oninput="this.className = ''"></td>
        <td> <?php echo $row->pil2;?></td>
    </tr>
    <tr>
        <td><input type="checkbox" class="w3-check" name="ket_jawaban[<?php echo $no2;?>]"  id="ket_jawaban[<?php echo $no2;?>]" value="<?php echo $row->pil3;?>" oninput="this.className = ''"></td>
        <td> <?php echo $row->pil3;?></td>
    </tr>
    $no++;
    $no2++;
}

And i my controller (i use Codeigniter)

public function insert_jawaban(){
        // Proses pemvalidasian data yg di input
        $this->form_validation->set_rules('ket_jawaban[]', 'ket_jawaban', 'trim|xss_clean');
        if ($this->form_validation->run() == FALSE){
            echo validation_errors(); // tampilkan apabila ada error
        }else{

            //Insert ke tabel jawaban
            $result = array();
            foreach($_POST['ket_jawaban'] AS $key => $val){

                $result[] = array(
                    "id_jawaban"    => '',
                    "user"          => $_POST['user'][$key],
                    "ket_jawaban"   => $_POST['ket_jawaban'][$key],
                    "id_pilgan"     => $_POST['id_pilgan'][$key],
                    "id_pertanyaan" => $_POST['id_pertanyaan'][$key],
                    "id_survey"     => $_POST['id_survey'][$key],
                    "nama"          => $_POST['nama_user'][$key],
                    "unit"          => $_POST['unit_user'][$key],
                    "jenis"         => $_POST['jenis_user'][$key]
                );
            }

            $res = $this->db->insert_batch('jawaban', $result);
}

why every time I checked always only returns one value, even though I checked three.

before I apologize if there is any wrong in my question is because I am newbie here. Thanks and please be advised




vendredi 22 décembre 2017

How to edit data array to checkbox with javascript

Table Form HTML

 <table id="example3" class="display" cellspacing="0" width="100%">
      <thead>
         <tr>
           <th></th>
           <th>Nama</th>
           <th>Unit</th>
        </tr>
      </thead>
    </table>

Javascript to headle select row

$('#frm-example').on('submit', function(e){ //on submit
            var form = this;

           var rows_selected = table3.column(0).checkboxes.selected();

            // Iterate over all selected checkboxes
            $.each(rows_selected, function(index, rowId){
            // Create a hidden element 
                $(form).append(
                    $('<input>')
                    .attr('type', 'hidden')
                    .attr('name', 'id[]')
                    .val(rowId)
                );
            });

My database

+-----------+--------------+---------------+-----------+-------------+-----------+------------------------------+---------------------+
| id_survey | judul_survey | status_survey | id_target | id_kategori | responden | detail_target                | tgl_survey          |
+-----------+--------------+---------------+-----------+-------------+-----------+------------------------------+---------------------+
|       130 | tes          | terbit        |         3 |           2 |         2 | 198411162009101002,H76215021 | 2017-12-19 15:08:35 |
+-----------+--------------+---------------+-----------+-------------+-----------+------------------------------+---------------------+
1 row in set (0.07 sec)

Data checkbox in field detail_kategori, how i can put this into form checkbox for update?

Ok, i get code checkbox from here http://ift.tt/2dDLkF4 I want modify the code to edit




Pass database values to checkbox using JavaFX 8

I've looked everywhere to find how to pass SQLite database values to a checkbox. This is for computer software used on a desktop or laptop. I doubt my programming would help anyone help me. Does anyone have ANY ideas at all?




WordPress ACF Checkbox loop

I currently have a CPT of 'restaurant'. Each restaurant can have multiple 'features', chosen by the user in the back end via a ACF checkbox field.

I'd like to be able to loop through this field and apply a class name for each checkbox that is checked.

In the below example, the restaurant has 3 of the 4 possible fields ticked. However, only the 'Parking' icon is showing (4 times) - likely due to my if statements.

Ideally, i'd like it to loop through each 'if', grab the string attached to $feature_icon and then spit it out in the echo further below in the span.

I've tried moving the section of if statements to be within the 'foreach' loop to no avail.

Any advice appreciated, thanks.

<?php if( $featured_restaurants ): ?>
<?php foreach ( $featured_restaurants as $featured_restaurant ): ?>

<div class="card__inputs"> <!-- Featured card specific icons start -->

<?php
    if(in_array('alcohol', $restaurant_features)):
        $feature_icon = "Alcohol";
    endif;

    if(in_array('family_friendly', $restaurant_features)):
        $feature_icon = "Family-Friendly";
    endif;

    if(in_array('open_late', $restaurant_features)):
        $feature_icon = "Open-Late";
    endif;

    if(in_array('parking', $restaurant_features)):
        $feature_icon = "Parking";
    endif;
?>

    <div class="details u-float-left"> <!-- Featured card specific icons container start -->
    <span class="icon icon--medium icon--Italian"></span>
    <?php if($restaurant_features): ?>
        <?php foreach($restaurant_features as $restaurant_feature): ?>
            <span class="icon icon--medium icon--<?php echo $feature_icon; ?>"></span>
        <?php endforeach; ?>
    <?php endif; ?>

    </div> <!-- Featured card specific icons container end -->

    </div> <!-- Featured card specific icons end -->

<?php endforeach; ?>
<?php wp_reset_postdata(); ?>
<?php endif; ?>




How to utilize bootstrap toggle with flask

This question is an extension of this question regarding using the Bootstrap toggle with flask.

My code for the toggle is as follows:

<div class='media'>
                <div class='media-left'>
                  <div class='media-object'>
                    <div class='padding-right'>
                      <form action="/menu" method="post">
                        <input name="toggle" onclick="this.form.submit()" data-off="&lt;i class='fa fa-times'&gt;&lt;/i&gt; " data-on="&lt;i class='fa fa-check'&gt;&lt;/i&gt; " data-onstyle='success' data-size='large' data-style='ios' data-toggle='toggle' id='activate-toggle' type='checkbox' value="on">
                        <input name="toggle" type="hidden" value="off">
                      </form>
                    </div>
                  </div>
                </div>
                <div class='media-body'>
                  <div id='console-event'></div>
                </div>
              </div>

And my endpoint for the page is as follows:

    @app.route('/menu', methods=['POST', 'GET'])
def get_callback():
    if request.method == 'POST':
        button = request.form['toggle']
        print(button)
    return render_template('dashboard.html')

However I am not able to get any response from my button.

I am very lost at this point. I have tried to copy the format of the question above however I still cannot get the button to print or even use the POST method.

Here are my questions:

  1. How can I get a response from my button?
  2. How do I save the orientation so that when the user logs back in the button is how they previously left it?

(I am using SQLAlchemy if this is of any importance.)

Any help would be greatly appreciated!

Thank you,

Jonah




More MySQL rows

Hey For School I have to centralize my colleagues' absences I've been thinking about using the databases. I creates a html form and a table in phpMyAdmin, for school subjects I use Checkboxes as you can see in the image, but if I select 2 subjects in the database I have only one register with first subject which I selected first. Can you give me a MySQL query to register twice with same name but different subjects like:

William:English:unmotivated absence
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
William:Chemistry:unmotivated :absence

Look




JavaScript to change value of textbox

This code is for an unsubscribe form, where I need to toggle whether or not a checkbox is checked on initial start, and then change values based on a user's selection.

Basically, I'm passing a value into the html through our email platform. If the value is I, the checkbox should be checked and the value I. Conversely, if the value is O, the checkbox should not be checked and the value O.

For the data to be passed back into our email platform I have to use a hidden input to capture the value, otherwise it won't actually send the I or O back.

The JavaScript, which I have as a tag in the head (HTML Email)

var initValue = function() {
    var permStat = document.getElementById("emailPref").value
    if(permStat === "I"){
      document.getElementById("checkbox").checked = true;
    } else {
      document.getElementById("checkbox").checked = false;
    }
  }
  var changeValue = function(){
    var optValue = document.getElementById("checkbox").value;
    if(optValue === "I"){
      document.getElementById("checkbox").value = "O";
      document.getElementById("emailPref").value = "O";
      document.getElementById("checkbox").checked = false;
    } else {
      document.getElementById("checkbox").value = "I";
      document.getElementById("emailPref").value = "I";
      document.getElementById("checkbox").checked = true;
    }
  }

The visible label for toggling the style (using CSS only)

<input type="checkbox" id="checkbox" name="emailPerm" value="$EMAIL_PERMISSION_STATUS_$" onload="initValue();" onclick="changeValue()">
<label class="toggle" for="checkbox"></label>

And the hidden input, the one that passes data back to our email platform

<input type="hidden" id="emailPref" name="EMAIL_PERMISSION_STATUS_" value="$EMAIL_PERMISSION_STATUS_$">

Additional info

On loading with I value, it appears as this (which would be the "O" value):

enter image description here

On clicking, after this state, the value does set to "O" and the styling remains the same. On a second click, the value goes back to "I" and displays properly:

enter image description here

**I apologize in advance if this is an obvious mistake, since I typically cannot use JavaScript in HTML emails but since this is technically presented as a landing page, it works.

Thanks!