mardi 28 février 2017

localstorage for checkboxes

Im trying to add localstorage to two ckeckboxes but the first checkbox behaves exactly like the secod even when they have different states. if first checkbox is unchecked and second is checked , on page reload the first becomes checked just like the second and when the second is unchecked , the first also becomes unchecked even if it was checked . I dont know why its behaving like a copy cat here is a github link to the project : http://ift.tt/2mryxLr

thanks

<div class="notify">
                <p>Send Email Notifications</p>
                <div class="onoffswitch toggleSwitch1" >
                    <input type="checkbox" name="onoffswitch" class="onoffswitch-checkbox" id="myonoffswitch" >
                    <label class="onoffswitch-label" for="myonoffswitch">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
                </div>
            </div>

            <div class="profile">
                <p>Set Profile To Public</p>
                <div class="onoffswitch toggleSwitch2" >
                    <input type="checkbox" name="onoffswitch2" class="onoffswitch-checkbox" id="myonoffswitch2" >
                    <label class="onoffswitch-label" for="myonoffswitch2">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
                </div>
            </div>


var save = document.getElementById("save");
save.addEventListener("click",saved,false);

window.onload=load;



var i;
var checkboxes = document.querySelectorAll('input[type=checkbox]');


function saved() {

  for(i = 0; i< checkboxes.length;i++){
    localStorage.setItem(checkboxes[i].value, checkboxes[i].checked);
  }
}

function load (){
  for(i = 0; i< checkboxes.length;i++){
    checkboxes[i].checked = localStorage.getItem(checkboxes[i].value) === "true"? true:false;
  }
}




Remove unchecked value from an array angular js

I am new to angular js. I have a checkbox with a table .

<td><input type="checkbox" ng-if="report.attributes.message.length > 0" ng-bind="report.attributes.message" ng-click="getcheckedData(report.attributes.message)"></td>

Here , I have a method getcheckedData(). So, In that method

                  var messages = [];



$scope.getcheckedData = function(SelectedVal) {     
                         $("input:checkbox[type=checkbox]:checked").each(function() {
                                if ($.inArray(SelectedVal , messages) === -1){
                                messages.push(SelectedVal);
                        }
                    });
                        return messages;
            };

I have an array which I declared globally,.So, I want to take the value of selected checkbox table data into that array. I am able to get that value in array. So, when user unchecks then the value which is unchecked should also get removed from that array . So, when user checks then , I have given one button on that I am sending all checked messages to the backend. So, When I uncheck and press the button that time all messages still remain in the array.

  $scope.sendAllMessages = function() {      
                        uploadService.SendMessagesToQueue(uploadService.currentFileName,$scope.documentType,messages)
                        .then(function () {
                        }, function (error) {
                            $scope.errorMessage = error.status + " : " + error.statusText;
                            toastr.error($scope.errorMessage, 'Error : ' + error.status);
                            if (error.status === 401) {
                                loginService.authenticationError();
                            }
                        })
                        .finally(function () {

                        });
                };

For button -

<button type="submit" 
                      ng-click = "sendAllMessages()" 
                      class="button-size btn btn-primary">Send
              </button>

so, How can I resolve this problem ?




multiple type errors -- confused --- adding css with jquery to checkboxes

Ok. super confused. I tried to run my code and got multiple type errors, and I am not entirely sure what they even mean, exactly.

What I am trying to do is create a grocery list, with checkboxes, and make it so that when a checkbox is checked, then it adds the css class "text-decoration: line-through" and when it is unchecked, it removes the line through. Help? Thank you :)

Uncaught TypeError: Cannot read property 'replace' of undefined
    at Function.camelCase (jquery.min.js:2)
    at Function.css (jquery.min.js:2)
    at init.<anonymous> (jquery.min.js:2)
    at Function.access (jquery.min.js:2)
    at init.css (jquery.min.js:2)
    at strikeout (check.js:6)
    at HTMLButtonElement.onclick (index.html:18)

here is my code:

js file:

function strikeout(){
var checkedbox = document.getElementsByName("grocery").checked;
if (checkedbox == true){
  $("checkedbox").css("text-decoration", "line-through");
} else {
  $("checkedbox").css();
}
}

html file:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">

    <title></title>

      <link rel="stylesheet" href="style.css">
  </head>
  <body><form>
    <h1>Shopping List</h1>
<ul><li><input type="checkbox" name="grocery" value="milk">Milk</li>
  <li><input type="checkbox" name="grocery" value="butter">butter</li>
  <li><input type="checkbox" name="grocery" value="eggs">eggs</li>
  <li><input type="checkbox" name="grocery" value="eggs">cheese</li>
  <li><input type="checkbox" name="grocery" value="coffee">coffee</li>
</ul>
<button type="button" onclick="strikeout()">Submit</button>
</form>
<script src="http://ift.tt/VorFZx"></script>
<script src="http://ift.tt/1eUYy5W"></script>
<script src="check.js"></script>

  </body>
</html>




Counting New Button Checks Using jQuery

Trying pass the number of newly checked, check boxes through Google Tag Manager:

function () { 
  var newChecks = 0;
  var counter = $('.checkBoxClass').change(function() 
  {
    if (this.checked) 
    {
      newChecks++;
    };
  })
  return newChecks;
}

When adding an alert to the this.checked function, it works well.
The only issue is that I am not seeing it pass through and save as a variable:

data not passing to variable

At this point I was also trying to run the .length of all checked boxes and by using .one run another parallel .length to capture the initial checkbox load for an equation of:

totalCheckBoxes - loadedCheckBoxes = total;
return total;

Feel like at this point there is something going on with GTM that I cannot see that's not saving the value.




angular 2 get value of checkbox [on hold]

<input type="checkbox">
<input type="checkbox">

for example if I have these two check boxes, how can I get the value of the checkbox in the typescript file, and I want to check only one of them to make form valid, so the user should check only one of them not both




array only storing checkboxes with value 1 (not 0)

I have checkboxes which change value using JavaScript and I want to store values of all checkboxes in a PHP array. But if the user changes the value of one checkbox to "0", the array created has only 2 values (1,1) instead of (1,0,1).

HTML

<input type="checkbox" name="cbox1[]" checked="checked" value="1" class="chbo">
<input type="checkbox" name="cbox1[]" checked="checked" value="1" class="chbo">
<input type="checkbox" name="cbox1[]" checked="checked" value="1" class="chbo">

PHP

$wer=$_POST['cbox1'];
echo implode(",",$wer);

Jquery

$(document).on('click', '.chbo', function() {
this.value ^= 1;
console.log(this.value);
});




Rendering a "normal" checkbox with ext.js 4

I'm trying to do something, i think, that should be relatively simple with EXT.js 4, but I can not find an answer. I'm trying to create a checkbox with a type of "checkbox" currently when I try it renders it as a type="button"

here is a sample of what I'm doing (I belive this code comes from Sencha itself, but it is what I am trying to do)

THIS CODE

Ext.create('Ext.form.Panel', {
bodyPadding: 10,
width      : 300,
title      : 'Pizza Order',
items: [
    {
        xtype      : 'fieldcontainer',
        fieldLabel : 'Toppings',
        defaultType: 'checkboxfield',
        items: [
            {
                boxLabel  : 'Anchovies',
                name      : 'topping',
                inputValue: '1',
                id        : 'checkbox1'
            }, {
                boxLabel  : 'Artichoke Hearts',
                name      : 'topping',
                inputValue: '2',
                checked   : true,
                id        : 'checkbox2'
            }, {
                boxLabel  : 'Bacon',
                name      : 'topping',
                inputValue: '3',
                id        : 'checkbox3'
            }
        ]
    }
],
bbar: [
    {
        text: 'Select Bacon',
        handler: function() {
            var checkbox = Ext.getCmp('checkbox3');
            checkbox.setValue(true);
        }
    },
    '-',
    {
        text: 'Select All',
        handler: function() {
            var checkbox1 = Ext.getCmp('checkbox1'),
                checkbox2 = Ext.getCmp('checkbox2'),
                checkbox3 = Ext.getCmp('checkbox3');

            checkbox1.setValue(true);
            checkbox2.setValue(true);
            checkbox3.setValue(true);
        }
    },
    {
        text: 'Deselect All',
        handler: function() {
            var checkbox1 = Ext.getCmp('checkbox1'),
                checkbox2 = Ext.getCmp('checkbox2'),
                checkbox3 = Ext.getCmp('checkbox3');

            checkbox1.setValue(false);
            checkbox2.setValue(false);
            checkbox3.setValue(false);
        }
    }
],
renderTo: Ext.getBody()

});

RENDERS

<input type="button" hidefocus="true" autocomplete="off" class="x-form-field x-form-checkbox x-form-cb" id="checkbox1-inputEl" aria-invalid="false" data-errorqtip="">

Notice the type="button"? I nee the type to be a "checkbox"

Let me include the reason, maybe I am approaching this wrong. I am trying to make JAWS reader read the checkbox the way it should. As a type "button" JAWS reader reads it like a button and dose not read the that goes with the check box.

Hope this makes since, please ask any question you need to and thanks for any help.

Ross




Making a CSS accordion open by clicking on plus sign OR the label

I found a great CSS/html codepen that allows me to view text in an accordion fashion when clicking on text inside the label element of class question, but there's only one problem I have with it:

The problem:

I can't use the plus-signs of class plus to also toggle the accordion. Instead, in the current implementation the accordions only open and allow me to view the answer if I click on the text inside the label elements of class question.

As things stand now, if I click on the plus sign (of class .plus), nothing happens. Can someone help me to modify this code so that clicking on either the plus-sign of class plus or the question text itself inside of the label element toggles the answers' visibility?

This is the codepen: http://ift.tt/2lvlGDK

This is the snippett:

@import url(http://ift.tt/2lPZvea);

body {
  font-family: 'Open Sans';
  font-size: 1.5em;
  background: #eee;
}

.content {
  width: 80%;
  padding: 20px;
  margin: 0 auto;
  padding: 0 60px 0 0;
}

.centerplease {
  margin: 0 auto;
  max-width: 270px;
  font-size: 40px;
}

.question {
  position: relative;
  background: #8FBC8F;
  margin: 0;
  padding: 10px 10px 10px 50px;
  display: block;
  width:100%;
  cursor: pointer;
}

.answers {
  background: #999;
  padding: 0px 15px;
  margin: 5px 0;
  height: 0;
  overflow: hidden;
  z-index: -1;
  position: relative;
  opacity: 0;
  -webkit-transition: .7s ease;
  -moz-transition: .7s ease;
  -o-transition: .7s ease;
  transition: .7s ease;
}

.questions:checked ~ .answers{
  height: auto;
  opacity: 1;
  padding: 15px;
}

.plus {
  position: absolute;
  margin-left: 10px;
  z-index: 5;
  font-size: 2em;
  line-height: 100%;
  -webkit-user-select: none;    
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
  -webkit-transition: .3s ease;
  -moz-transition: .3s ease;
  -o-transition: .3s ease;
  transition: .3s ease;
}

.questions:checked ~ .plus {
  -webkit-transform: rotate(45deg);
  -moz-transform: rotate(45deg);
  -o-transform: rotate(45deg);
  transform: rotate(45deg);
}

.questions {
  display: none;
}
<div class='centerplease'>
  FAQ accordion
</div>
<br>

<div class="content">
<div>
  <input type="checkbox" id="question1" name="q"  class="questions">
  <div class="plus">+</div>
  <label for="question1" class="question">
    This is the question that will be asked?
  </label>
  <div class="answers">
    What if the answer is really long and wraps the whole page and you never want to finish it but you have to because its the answer!
  </div>
</div>

<div>
  <input type="checkbox" id="question2" name="q" class="questions">
  <div class="plus">+</div>
  <label for="question2" class="question">
    Short?
  </label>
  <div class="answers">
    short!
  </div>
</div>
  
<div>
  <input type="checkbox" id="question3" name="q" class="questions">
  <div class="plus">+</div>
  <label for="question3" class="question">
    But what if the question is really long and wraps the whole page and you feel like you will never finish reading the question?
  </label>
  <div class="answers">
    This is the answer!
  </div>
</div>
</div>



How to check multiple checkboxes programmatically in a formGroup on reactive form?

I am using Angular2 RC 5, and trying to implement a reactive form (model driven)

I defined the checkboxes like so

usageRights : new FormGroup({
         all_usage   : new FormControl( '' ),
         digital     : new FormControl( '' ),
         outdoor     : new FormControl( '' ),
         print       : new FormControl( '' ),
         radio       : new FormControl( '' ),
         tv          : new FormControl( '' )
})

There is a button and when it is clicked, I like to check all the checkboxes in the group. My current implementation is using a function on click of the button but I cannot figure out how I can check these checkboxes in my ts file

My checkAll function

checkAll( control, e ) {
    e.preventDefault();
    console.log(control);
}

control is the formGroup(usageRights) that contains all the checkboxes, and it logs fine. I believe I can just use a variable in combination with [checked], then update the variable when clicked on the button but I feel like this is not the proper way of doing this.

Someone please tell me how this should be done. I am stuck.




Laravel dom-pdf issue sending id value and checkboxes to pdf

Could anyone help me by explaining how to dynamicaly update data in laravel dom-pdf file?

i have an isssue with sending an id value to pdf file and dynamically representing data in pdf file using dom-pdf for laravel. I use Laravel 5.3.28

->I have a search form with wich user finds specific post address (every address have an unique id value for it)

->after that - user is sent to a page (view) where he/she can choose to click on multiple checkboxes (or dont click on any of them at all) for more options for the specific adress.

_>After this user is sent to a view where he/she can click on an pdf icon image and download the generated pdf file.

In this file there should be an information taken from database based on selected adress (selected by its id value) and if the user has chosen some of the options from the checkboxes also the text, values for that specific checkboxes. I hope you understood what im trying to do.

The problem is that i can't send the specific id values to this pdf file for dynamic content update, also the checkboxes are not working properly.

Sorry for my english.

Here is my controller file:

class ItemController extends Controller
{
    public function pdfview()
    {
    //$items = DB::table("lv_cities")->get();
    //$items = Input::get('info');
    $objid = Input::get('objid');
    $results = streetnr::where('streetnrid', "=", $objid)->get();
    return view('pdf.pdfview')->with('results',$results)->with('objid',$objid); 
    }

    public function pdfview2(Request $request,$id)
    {
    //$objid = Input::get('objid');
    //$results = streetnr::where('streetnrid', "=", $objid)->get();
    $objid = streetnr::findOrFail($id);
    $results = DB::table('lv_streetnr')->first();
    view()->share('results',$results);
    $pdf = PDF::loadView('pdf.pdfreport',['objid' => $objid]);
    return $pdf->download('report.pdf', array('Attachment'=>0));
    //$pdf = PDF::loadView('pdf.pdfreport', compact('objid','results', 'opt1html', 'opt2html', 'opt3html', 'opt4html', 'opt5html', 'opt6html', 'opt7html', 'opt8html', 'opt9html', 'opt10html', 'opt11html', 'opt12html', 'opt13html'));
    //$pdf->loadView('pdf', array('data' => 'test'));
    //return $pdf->download('propertyinfo.pdf');
    }

here is my routes

Route::get('pdfview', 'ItemController@pdfview');
Route::get('pdfview2/{id}', 'ItemController@pdfview2');

here is my pdfview view file

@extends('layouts.app')
@section('content')
 <div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
<div class="panel-body">
            @if (Auth::check())
                    You <B>are</B> logged in!<BR>
<div class="alert alert-info">
  Download report for property <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><BR>
  <a href="pdfview2/"><img src="http://ift.tt/2m919sd" style="width:10%;height:10%;">
  <BR>
    Download PDF</a>
</div>
    <BR>
            <input name="objid" type="hidden" value="">
            homename/streename id: <BR>       
                @else
                    You <B>are not</B> logged in!<BR><BR><BR>
            @endif
                </div></div></div></div></div>@endsection

here is my pdfreport view file - this is the file from wich the pdf file is generated:

<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style type="text/css">
body {
    font: normal 10px Verdana, Arial, sans-serif;
}
.page-break {
    page-break-after: always;
}
</style>
    </head>
    <body>
<BR>
ID: {!!$objid->property!!}
@if(isset($results->streetnrid)) streetnr id: <BR> @endif
@if(isset($results->streetname)) streetname: <BR> @endif
@if(isset($results->streetnr)) streetnr: <BR> @endif
@if(isset($results->id)) DB ID: <BR> @endif
@if(isset($results->village_n)) village name: <BR> @endif
@if(isset($results->parish_n)) parish name: <BR> @endif
@if(isset($results->city_n)) city name: <BR> @endif
<div class="page-break"></div>

            @if(isset($opt1)) opt1 is checked @endif
            @if(isset($opt2)) opt2 is checked @endif
            @if(isset($opt3)) opt3 is checked @endif
            @if(isset($opt4)) opt4 is checked @endif
            @if(isset($opt5)) opt5 is checked @endif
            @if(isset($opt6)) opt6 is checked @endif
            @if(isset($opt7)) opt7 is checked @endif
            @if(isset($opt8)) opt8 is checked @endif
            @if(isset($opt9)) opt9 is checked @endif
            @if(isset($opt10)) opt10 is checked @endif
            @if(isset($opt11)) opt11 is checked @endif
            @if(isset($opt12)) opt12 is checked @endif
            @if(isset($opt13)) opt13 is checked @endif
    </body>
</html>

and here is the starting view file in which user can click on checkboxes etc.

@extends('layouts.app')
@section('content')
 <div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="panel panel-default">
            <div class="panel-body">
            @if (Auth::check())
            You <B>are</B> logged in!<BR><BR><BR>
            <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong><br>
            <strong></strong>
            <BR>
            ID: 
<BR>
<form method="get" action="pdfview">
<input name="objid" type="hidden" value="">
<b>Basic options - 3.50 EUR</b><br/>
<input type="checkbox" name="opt1" value="3.00">Options 1 - 3 EUR<br/>
<input type="checkbox" name="opt2" value="1.50">Options 2 - 1.50 EUR<br/>
<input type="checkbox" name="opt3" value="3.60">Options 3 - 3.60 EUR<br/>
<input type="checkbox" name="opt4" value="2.50">Options 4 - 2.50 EUR<br/>
<input type="checkbox" name="opt5" value="2.80">Options 5 - 2.80 EUR<br/>
<input type="checkbox" name="opt6" value="2.50">Options 6 - 2.50 EUR<br/>
<input type="checkbox" name="opt7" value="3">Options 7 - 3 EUR<br/>
<input type="checkbox" name="opt8" value="2.50">Options 8 - 2.50 EUR<br/>
<input type="checkbox" name="opt9" value="2.50">Options 9 - 2.50 EUR<br/>
<input type="checkbox" name="opt10" value="3.50">Options 10 - 3.50 EUR<br/>
<input type="checkbox" name="opt11" value="3.50">Options 11 - 3.50 EUR<br/>
<input type="checkbox" name="opt12" value="2.50">Options 12 - 2.50 EUR<br/>
<input type="checkbox" name="opt13" value="3">Options 13 - 3 EUR<br/>
<h2>Kopā: <span name="total" class="total">3.50</span> EUR</h2>
<BR><input type="submit" id="adress_submit" value="search" class="btn btn-primary">
</form>
@else
You <B>are not</B> logged in!<BR><BR><BR>
@endif
</div>
<script>
$(function() {
$('input').click(function(){
var total = 3.50;
$('input:checked').each(function(index, item) {
total += parseFloat(item.value);
});
$('.total').text(total);
});
}); 
</script>
@endsection
</body>
</html>




Kivy: how to set checkbox to checked on start up

How can I set the status of the checkbox with the id set to blue to be checked on start up. I use python 3.6 and Kivy 1.9.2.dev0. I thought the lines blue = ObjectProperty(True) in .py and value: root.blue in .kv would do that but apparently I am misunderstanding how ObjectProperty works

import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.core.window import Window

class SampBoxLayout(BoxLayout):

    # For radio buttons
    blue = ObjectProperty(True)
    red = ObjectProperty(False)

class SimpleApp(App):
    def build(self):
        Window.clearcolor = (1, 1, 1, 1)
        return SampBoxLayout()

sample_app = SimpleApp()
sample_app.run()

The .kv:

#: import CheckBox kivy.uix.checkbox


<SampBoxLayout>
    orientation: "vertical"
    padding: 10
    spacing: 10
    BoxLayout:
        orientation: "horizontal"
        size_hint_x: .55
        Label:
            text: "Favorite Color:"
            color: 0, 0, 0, 1
            size_hint_x: .265
        Label:
            text: "Blue"
            color: 0, 0, 0, 1
            size_hint_x: .15
        CheckBox:
            group: "fav_color"
            id : blue
            value: root.blue
            size_hint_x: .05
        Label:
            text: "Red"
            color: 0, 0, 0, 1
            size_hint_x: .15
        CheckBox:
            group: "fav_color"
            value: root.red
            size_hint_x: .05




Kivy: how to print instance id

I have this code and I would like to print the instance id once a checkbox is checked. I tried instance.id and self.ids.instance.ids but without success. Simply printing the instance gives me the kivy name (like <kivy.uix.checkbox.CheckBox object at 0x0000000005969660>). I use python 3.6 and Kivy 1.9.2.dev0.

import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty
from kivy.core.window import Window

class SampBoxLayout(BoxLayout):

    # For radio buttons
    blue = ObjectProperty(True)
    red = ObjectProperty(False)

    def checkbox_color(self, instance, value):
        if value is True:
            print("Is checked", instance.id)  # How to print the instance ID (I also tried  self.ids.instance.ids)
        else:
            print("Is not checked")

class SimpleApp(App):
    def build(self):
        Window.clearcolor = (1, 1, 1, 1)
        return SampBoxLayout()

sample_app = SimpleApp()
sample_app.run()

The .kv:

#: import CheckBox kivy.uix.checkbox


<SampBoxLayout>
    orientation: "vertical"
    padding: 10
    spacing: 10
    BoxLayout:
        orientation: "horizontal"
        size_hint_x: .55
        Label:
            text: "Favorite Color:"
            color: 0, 0, 0, 1
            size_hint_x: .265
        Label:
            text: "Blue"
            color: 0, 0, 0, 1
            size_hint_x: .15
        CheckBox:
            group: "fav_color"
            id : blue
            value: root.blue
            size_hint_x: .05
            on_active: root.checkbox_color(self, self.active) 
        Label:
            text: "Red"
            color: 0, 0, 0, 1
            size_hint_x: .15
        CheckBox:
            group: "fav_color"
            value: root.red
            size_hint_x: .05
            on_active: root.checkbox_color(self, self.active)

As a side question, how can I set the status of the checkbox with the id set to blue to be checked on start up (I thought the line blue = ObjectProperty(True) would do that)




Dynamic ng-model binding to object properties inside ng-repeater

I require a bit of help with AngularJS syntax to make a dynamic checkbox selector bind to object properties.

Problem:

<div ng-repeat="level in vm.Settings.LevelList">
    <input type="checkbox" ng-model="vm.Item.Level." ng-change="CheckLevel()"> 
<div>

Where items' level is just a key-value-pair object. It's important to note that not all levels may be applicable to an item but each item will have an object with all possible options as follows:

Item.Level = {
    L1: false,
    L2: true,
    L3: false,
    L4: false,
}

My vm.Settings.LevelList changes depending on the page that is loaded. To make things simple let's assume we have the following array to work with:

Settings.LevelList = [
    { Name: 'Level 2', ShartName: 'L2', SortOrder: 2, },
    { Name: 'Level 3', ShartName: 'L3', SortOrder: 3, },
]

My template spells out all possible options where I am using ng-if to hide ckeckboxes that are not relevant. While I am not expecting for levels to change often at the same time I do not want to spend my time tracking every template where level checkboxes apear. So, the following is what I currently have:

<div ng-if="conditon to hide L1"><input type="checkbox" ng-model="vm.Item.Level.L1" ng-change="CheckLevel()"> Level 1</div>
<div ng-if="conditon to hide L2"><input type="checkbox" ng-model="vm.Item.Level.L2" ng-change="CheckLevel()"> Level 2</div>
<div ng=if="conditon to hide L3"><input type="checkbox" ng-model="vm.Item.Level.L3" ng-change="CheckLevel()"> Level 3</div>
<div ng-if="conditon to hide L4"><input type="checkbox" ng-model="vm.Item.Level.L4" ng-change="CheckLevel()"> Level 4</div>

But what I want should be of the following form:

<div><input type="checkbox" ng-model="vm.Item.Level.L2" ng-change="CheckLevel()"> </div>
<div><input type="checkbox" ng-model="vm.Item.Level.L3" ng-change="CheckLevel()"> </div>

So, the repeater should only need to produce two checkbox options as per Settings.LevelList. Provided the model binds correctly checkbox for Level 2 should be checked (Item.Level.L2 = true).

Just in case someone wonders CheckLevel() just makes sure that at least one level option is selected. Also, I am working with AngularJS v1.5.8.




How to display Checkbox list based on Dropdown selection? asp.net vb

i have dropdownlist read from database (tbl_role) i want select from dropdownlist then display checkbox(tbl_section) check if had permission or not

thanks in advance




PyQT : How to get checkable items from treeview?

I am a newbie to PyQT and I need some help. I have defined a treeview with checkable items using QStandardItemModel and item.setCheckable(True). That's working. Now, I want to get checkable items and to launch a new interface with these checkable items. I tried to use selected indexes but I don't know how to get checked items. I am really confused and I don't like to use QtreeWidget.

Any ideas to do that ? Iterate over a treeview and get checkable items ?

Thank you in advance.




Symfony CheckboxType could not be unchecked

Here are the existing codes:

Form type as :

->add('isProcessor', CheckboxType::class,array('label' => 'As Processor', 'required'=>false))

Entity as:

/**
 * @var boolean $isProcessor
 *
 * @ORM\Column(name="is_processor", type="boolean")
 * @Assert\NotBlank()
 */
private $isProcessor;

page as : enter image description here

How could I make this happen:

  • if the checkbox is checked, isProcessor should be true
  • if the checkbox is unchecked, isProcessor should be false

I am not if there should be some other parameters with CheckboxType when building the form. Or I need add some other codes to convert the values.

Also the field could not be modified in modify page. Is there any way to make the checkbox element disable in modify page but enable in create page?

Thank you very much for your help.




how to display a php variable in input checkbox

i made a small user database with some checkboxes in a html input form. in there i have some basic infos about the users like value 1 and 2 (among others) and some checkboxes as well (here you see one). default is always 0, but when i click the checkbox its changes to 1.

<input type="text" placeholder="Value 1" value="<?php echo set_value('value1'); ?>" name="value1" size="6"/>
<input type="hidden" value="0" name="spec1"/><input type="checkbox" value="1" name="spec1"/>
<input type="text" placeholder="Value 2" value="<?php echo set_value('value2'); ?>" name="value2" size="6"/>

now i would like to have a form in which i can see all these informations later on and edit it if necessary. but the checkbox i cant display properly. it is always empty. so i had to change it to a textbox. so i can see whether that specific values are 0 or 1.

<input type="text" name="Value 1" value="<?php echo $value1; ?>">
<input type="text" name="spec1" value="<?php echo $spec1; ?>">
<input type="text" name="Value 2" value="<?php echo $value2; ?>">

is it possible somehow to show the values in a checkbox again, so i can change the type of the second line to "checkbox" again instead of "text"? means can i display a value 1 as a checked checkbox and 0 as an empty checkbox?




lundi 27 février 2017

Eclipse IDE - Increase size of dotted outline on dialogue checkboxes

Please see the example picture below, the dotted line around the checkbox question. How do I increase its size in Eclipse IDE? My current size is too small and makes the text unreadable.

enter image description here




PHP - MySql : How to store and retrieve checkbox value with other option

I using checkbox to get and store interest of user.

enter image description here

Store these data in database mysql with comma separated

enter image description here

My php code for retrive these data and display in html page

<?php

....

// Get data
$result = profile($uname);
$result['interest'] = explode(',', $result['interest']);

?>

....

<div class="col-sm-6">
    <div class="form-check checkbox-style">
        <label class="label-weight">Interests</label><br>
        <label class="form-check-label label-weight">
            <input type="checkbox" class="form-check-input" name="interest[]" onclick="return interest_validate(this);" id="selectall"><span class="check-label-pad"> Select all</span></label></label><label for="" class="opacity-set label-set" id="select-label"></label><br>
        <label class="form-check-label label-weight">
            <input type="checkbox" class="form-check-input" name="interest[]" onclick="return option_select(this);" value="option1" <?php echo in_array('option1',$result['interest']) ? 'checked' : ''; ?>><span class="check-label-pad">Option 1</span></label><br>
        <label class="form-check-label label-weight">
            <input type="checkbox" class="form-check-input" name="interest[]" onclick="return option_select(this);" value="option2" <?php echo in_array('option2', $result['interest']) ? 'checked' : ''; ?>><span class="check-label-pad">Option 2</span></label><br>
        <label class="form-check-label label-weight">
            <input type="checkbox" class="form-check-input" name="interest[]" onclick="return option_select(this);" value="option3" <?php echo in_array('option3', $result['interest']) ? 'checked' : ''; ?>><span class="check-label-pad">Option 3</span></label><br>
        <label class="form-check-label label-weight">
            <input type="checkbox" class="form-check-input" name="interest[]" id="other_checkbox" onclick=" return other_validate(this);" value="other"><span class="check-label-pad"  >Other</span> &nbsp;&nbsp;</label><input type="text " class="text-style-other opacity-set" id="other-text" onblur="return other_text_validate();" />
        <label for="" class="opacity-set label-set" id="other-text-label"></label>
    </div>
</div>

Issue : in edit mode, I am using "in_array()" for to give as default checked to checkbox as per database value. But how to check "Other" (check attached image) option and display value ? which condition i need to add here?




NAVIGATION DRAWER: Saving a single checkbox state from the fragment

I am brand new to android programming and know this question has popped a lot, but no clear single answer to formulate a solution is given:

SAVING A CHECKBOX VALUE IN A FRAGMENT FROM A NAVIGATION DRAWER.

I only need to see the structure of the fragment to understand how to implement the save preferences , just a simple checkbox nothing else.

Kind Regards

MENU FRAGMENT:

public class Menu1 extends Fragment {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup     container, @Nullable Bundle savedInstanceState) {
    //returning our layout file
    //change R.layout.yourlayoutfilename for each of your fragments
    return inflater.inflate(R.layout.fragment_menu_1, container, false);
}


@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //you can set the title for your toolbar here for different fragments     different titles
    getActivity().setTitle("MODEL 1");
}

LAYOUT:

<RelativeLayout 
android:layout_width="match_parent"
android:layout_height="match_parent">

<CheckBox
    android:text="@string/checkbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="158dp"
    android:id="@+id/checkBox" />
</RelativeLayout>




Display highest value from checkbox selections in gravity forms

I have a form on my site with a multi-select checkbox list. Each item in the list has a number assigned to it (some are duplicates). I want the user to be able to select multiple options from the list, and for gravity forms to collect the highest number selected.

The reason for all of this is I have multiple confirmations that display different options using conditional logic based on the highest number selected. So if the user selects 3 options all with the value of 1, the form will return the confirmation of 1. but if they select a 1 and a 2, I want it to show the result for 2. gravity forms just finds the first value selected and uses it as the result. (in this case, 1)

If anyone has a fix I greatly appreciate it. Thank you.




get table rows only when table checkbox is "checked"

I am using below code to get the values of selected row using check box class = btnSelect; but i want to get the rows only when the checkbox is marked as checked. Current code get the values , both when checkbox checked and unchecked.Someone please help me on how to change the code to get the required thing

$("#itemtable").on('click','.btnSelect',function(){
                     // get the current row 
                         alert("i am inside dddd");
                        var currentRow = $(this).closest("tr"); 

                        var col1 = currentRow.find("td:eq(0)").text(); // get SI no from checkbox
                        var col2 = currentRow.find("td:eq(1)").text(); // get item name
                        var col3 = currentRow.find("td:eq(2)").text(); // get item code
                        var col4 = currentRow.find("td:eq(3)").text(); // get supplier
                        var col5 = currentRow.find("td:eq(4)").text(); // get received qty
                        var col6 = $(currentRow).find("td:eq(5) input[type='text']").val(); // get accepted qty
                        var col7 = $(currentRow).find("td:eq(6) input[type='text']").val(); // get rejected qty
                        var col8 = $(currentRow).find("td:eq(7) input[type='text']").val(); // get remarks
                       
                        var data=col1+"\n"+col2+"\n"+col3+"\n"+col4+"\n"+col5+"\n"+col6+"\n"+col7+"\n"+col8;
                        
                        alert(data);
                       });



Meteor checkbox always false after Template render

I have a navbar with 2 entries. One entrie is a checkbox and the other one is a dropdown with a button (I will provide code for that). The input has the id inputMode and the button addNewObject

 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav">
            <li id="editMode">
               <a href="#">
                   <label><input type="checkbox" value="Edit Mode" id="inputMode">Edit Mode</label>
               </a>
            </li>
            <li><a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                   aria-haspopup="true" aria-expanded="false">Scenegraph <span class="caret"></span></a>
                <ul class="dropdown-menu">
                    <li><div style="text-align:center;">
                        <input id="addNewObject" type="button" class="btn-success" value="Add Object">
                    </div></li>
                </ul>
            </li>

        </ul>
    </div>

For each of the id's i have click function's.

'click #inputMode': function (event, tmpl) {
    let isChecked = $("#inputMode").is(":checked");
    if (isChecked) {
       // do something
    } else {
      //do something
    }
},
'click #addNewObject': function (ev) {

    Helper.initSceneGraph();

}

So the thing is when i click the button addNewObject the navbar gets rerendered, like this:

static initSceneGraph() {
    if (Meteor.isClient) {
        Template.sceneGraph.helpers({
            sceneObjects: Application.getInstance().scene.sceneObjects,
            isAudio: function (obj) {
                return obj._soundPath;
            }
        });
    }
    UI.render(Template.sceneGraph, document.body);
}

So after the initSceneGraph the checkbox inputMode doesnt change. That means visually it changes, but intern it always stays the same. For exampleconsole.log($("#inputMode").is(":checked"); is either ALWAYS false or ALWAYS true, depending if it was true or false BEFORE clicking the button.

I hope someone can help me out with this!




How to get the name of checked checkboxes and store them in a database with using php

I have 4 checkboxes in html, and at the same time, only 2 can be selected from them. I would like to store the selected ones in a database, but I'm not sure how to put that into code. So if you could help me guide a way to storing the checked in checkboxes in a database, that would be really appreciated!

            <div id="chooseTeacher" style="margin-bottom:24px;">
                <label id="selectTeacher" class="form-control">Select your teacher(s)</label>
                <table style="width:auto;text-align:left;margin-bottom:1px;margin-top:13px" >
                    <tr>                                                  
                        <th style="font:inherit;display:flex;">
                            <input type="checkbox" id="archer" name="archer" style="display:none; position:absolute; left:9999px;" onclick="countCheckedBoxes(this)">
                            <label for="archer" style="margin-right:68px;"><span></span>Miss Archer</label>
                  
                            <input type="checkbox" id="craig" name="craig" style="display:none; position:absolute; left:9999px;" onclick="countCheckedBoxes(this)">
                            <label for="craig"><span></span>Miss Craig</label>
                        </th>
                        <th style="font:inherit;padding-right:110px;display: flex;"> 
                            <input type="checkbox" id="devine" name="devine" style="display:none; position:absolute; left:9999px;" onclick="countCheckedBoxes(this)">
                            <label for="devine" style="margin-right:65px;"><span></span>Miss Devine</label> 
                                                               
                            <input type="checkbox" id="dorrity" name="dorrity" style="display:none; position:absolute; left:9999px;" onclick="countCheckedBoxes(this)">
                            <label for="dorrity"><span></span>Miss Dorrity</label>  
                        </th>                   
                    </tr> 
                </table>
            </div>

(IN THE SNIPPET THE CHECKBOXES CAN'T BE SEEN BECAUSE I USED ANIMATIONS WITHIN CSS)




Android: Saving a Single Checkbox in Navigation Drawer Fragment

I am brand new to android programming and know this question has popped alot, although, I can seem to decipher the code to understand how it works. What I need is to save the checkbox state when switching to another fragment. But also I don't just need the code, I need to understand how exactly to program more if needed. I am really sorry that you might get upset as this seems easy, but I need a step by step explanation how to do it.. Please can someone assist me.

Kind Regards




Listview load checked checkboxes when click edit button wpf

xml code

<ListView Name="lstvPermissions" BorderBrush="White" BorderThickness="0.4" Height="190" MinHeight="190" MaxHeight="325" Margin="10">
                        <ListView.ItemsPanel>
                            <ItemsPanelTemplate>
                                <WrapPanel Width="{Binding (FrameworkElement.ActualWidth), 
        RelativeSource={RelativeSource AncestorType=ScrollContentPresenter}}"
        ItemWidth="{Binding (ListView.View).ItemWidth, 
        RelativeSource={RelativeSource AncestorType=ListView}}"
        MinWidth="{Binding ItemWidth, RelativeSource={RelativeSource Self}}"
        ItemHeight="{Binding (ListView.View).ItemHeight, 
        RelativeSource={RelativeSource AncestorType=ListView}}" />
                            </ItemsPanelTemplate>
                        </ListView.ItemsPanel>
                        <ListView.View>
                            <GridView>
                                <GridViewColumn>
                                    <GridViewColumnHeader>
                                        <TextBlock Text="Permissions"/>
                                    </GridViewColumnHeader>
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <CheckBox Content="{Binding prsnRolDTitle}" IsChecked="{Binding Mode=TwoWay, RelativeSource={RelativeSource AncestorType=ListViewItem},Path=IsSelected}"/>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>

cs code

 lstvPermissions.ItemsSource = AS.Tbl_PersonRolesDetail.ToList();

my above code working fine and look like this:

selected permissions insert database and show these roles in datagrid, now when I click datagrid edit button title field and description field filled but I don't no how I load checked checkboxes to see previously I assigned permissions. Thanx in advance for any help.




How to post id on checkbox in Jquery?

I want to make a simple pagination page. This is regarding delete function. I have a checkbox that user can choose to delete a row. May I know how to post/get the id of the row if user click on next link? In my case, the id will be duplicate if user click on the checkbox. Below are my codes,

jQuery

var cbNew = [],
cbAdd = [];

function addId(checkBox){
    cbAdd = cbAdd.concat(checkBox);
    console.log(cbAdd);
}

$(document).on("click", ".checkBox", function(){
    var cb = [];
    $('.checkBox:checked').each(function(){
        cb.push($(this).val());
    });

    if(cb.length > 0) { 
        addId(cb);
        $('#delete').fadeIn(); 
    } else {
        $('#delete').fadeOut();
    }
});

//Link on Next Page
$(".nextPage").click(getFunct);

function getFunct(e){
    e.preventDefault();
    var url = $(this).attr('href'),
    row = getURLParameter(url, 'startrow'),
    cbNew = cbNew;
    getParam(row,url);
}

function getParam(param1,param2){
    $.ajax({
        type: "POST",
        url: url,
        data: 
        {
            row : param1,
            url : param2,
            cbNew : cbNew
        }
    }).done(function(data){
        $('#result').html(data);
        addId(cbNew);
    });
}

This is the output if I click on multiple checkbox on same page console.log(cbAdd);

["25", "25", "26", "25", "26", "27"]

If I click one checkbox on page 1 and one checkbox on page 2, it get the id correcltly

["25", "59"]




How to use Checked event properly?

I am trying to make app which will create excel sheets for multiple paths based on checkboxes.

Now i am trying create a method which will create files for checked CheckBoxes.

private void createFilesButton_Click(object sender, RoutedEventArgs e)
        {
            for (int index = 0; index < projektCheckBoxes.Count; ++index)
            {
                if (projektCheckBoxes[index].Checked)
                {
                    vytvorSoubor(index);
                    }
            }

My problem is that I am getting this fault:

Error CS0079 The event 'ToggleButton.Checked' can only appear on the left hand side of += or -=

I was searching through this forum so i tried IsChecked then i got this fault:

Error CS0266 Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)

So i searched again and i found answer that Checked is an event and that I should use the IsChecked property like this...

  if (projektCheckBoxes[index].IsChecked ?"It's checked" : "Not checked")

but this didn't helped me either.

Could you please give me advise what I am doing wrong and how it should be correctly?

Thx!




Select many checkbox ajax update view on second event

I'm trying to filter a datatable on categories using a select selectManyCheckbox. The idea is that when a checkbox is clicked, the datatable values are updated. Now the problem is that the values are updated after selecting a checkbox twice, but this results in a datable with incorret values. Here is my xhtml page.

<p:layout id="dossierLayout" widgetVar="dossierLayout">
                <p:layoutUnit id="categoriesLayoutUnit" position="west"
                              header="#{msg['dossier.page.layoutWest.header']}">
                    <p:selectManyCheckbox id="dossierCategories" value="#{dossierBean.dossierFileCategoriesFilter}"
                                          layout="pageDirection" columns="1" converter="dossierCategorieConverter" immediate="true">

                        <f:selectItems value="#{dossierBean.dossierFileCategorieList}" var="dossierCategorie"
                                       itemLabel="#{dossierCategorie.categorieDescription}"
                                       itemValue="#{dossierCategorie}"/>
                        <p:ajax listener="#{dossierBean.filterfiles}" update="dossierForm:dossierFiles" />
                    </p:selectManyCheckbox>
                </p:layoutUnit>

                <p:layoutUnit id="dossierFilesLayoutUnit" position="center">
                    <p:dataTable id="dossierFiles" value="#{dossierBean.filteredFiles}" widgetVar="dossierFiles" filteredValue="#{dossierBean.filteredFiles}" var="dossierFile">

                        <f:facet name="header">
                            <p:outputPanel>
                                <h:outputText value="#{msg['dossier.page.datatable.globalSearch.label']}"/>
                                <p:inputText id="dossierNameFilterInput" value="#{dossierBean.dossierNameFilter}"/>
                                <p:watermark id="dossierNameFilterInputWaterMark" for="dossierNameFilterInput" value="#{msg['dossier.page.layoutWest.header.watermark']}"/>
                            </p:outputPanel>
                            <p:commandButton id="dossierNameFilterSearch" value="#{msg['cmn.search']}" actionListener="#{dossierBean.filterFilesByName}" update="dossierFiles"/>
                            <p:commandButton id="dossierNameFilerSearchEmpty" value="#{msg['cmn.clear']}" actionListener="#{dossierBean.clearFilterName}" update="dossierFiles"/>
                        </f:facet>

                        <p:column id="dossierFileName" filterBy="#{dossierFile.nameDocument}" filterStyle="display: none;" filterMatchMode="contains" headerText="#{msg['dossier.page.datatable.columheader.Name']}">
                            <h:outputText styleClass="#{dossierFile.dossierFileIcon.docType}"/>
                            <h:outputText value="#{dossierFile.nameDocument}"/>
                        </p:column>

                        <p:column id="dossierFileLastChanged" headerText="#{msg['dossier.page.datatable.columheader.Date']}">
                            <h:outputText value="#{dossierFile.dateLastChange}"/>
                        </p:column>

                        <p:column id="dossierFileUser" headerText="#{msg['dossier.page.datatable.columheader.User']}">
                            <h:outputText value="#{dossierFile.user}"/>
                        </p:column>

                        <p:column id="dossierFileCategorie" headerText="#{msg['dossier.page.datatable.columheader.Categorie']}">
                            <h:outputText value="#{dossierFile.categorie.categorieDescription}"/>
                        </p:column>

                        <p:column id="dossierFileLocation" headerText="#{msg['dossier.page.datatable.columheader.Location']}">
                            <h:outputText value="#{dossierFile.nameFolder}"/>
                        </p:column>

                    </p:dataTable>
                </p:layoutUnit>
             </p:layout>




dimanche 26 février 2017

Why the unchecked state ís not being saved?

I have an activity in which there is one checkBox, now the problem arises that when the checkBox is in checked state it remains checked no issues, But when i uncheck it, it revert back to its checked condition. Why is this happening? Here, is my code, i have used shared Preference.

 public class Kinematics extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, CompoundButton.OnCheckedChangeListener {
    private DrawerLayout drawerLayout;
    private NavigationView navigationView;
    private ActionBarDrawerToggle phy_law_toggel;
    private Toolbar toolbar;
    private WebView webView;
    private FloatingActionButton floatingActionButton;
    private RelativeLayout relativeLayout;
    private CheckBox checkBox;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_kinematics);
        Toolbar toolbar = (Toolbar) findViewById(R.id.phy_lawtoolbar);
        setSupportActionBar(toolbar);
        setTitle(R.string.Kinematics);
        relativeLayout = (RelativeLayout) findViewById(R.id.relative);
        drawerLayout = (DrawerLayout) findViewById(R.id.phy_draw);
        navigationView = (NavigationView) findViewById(R.id.nav_view_phy);
        phy_law_toggel = new ActionBarDrawerToggle(this, drawerLayout, R.string.open, R.string.Close);
        drawerLayout.addDrawerListener(phy_law_toggel);
        toolbar = (Toolbar) findViewById(R.id.phy_lawtoolbar);
        setSupportActionBar(toolbar);
        phy_law_toggel.syncState();
        checkBox = (CheckBox) findViewById(R.id.fav);
        checkBox.setChecked(getAsp("checkbox"));
        checkBox.setOnCheckedChangeListener(this);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        navigationView.setItemIconTintList(null);
        webView = (WebView) findViewById(R.id.phy_law_web);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setBuiltInZoomControls(false);
        webView.loadUrl("file:///android_asset/mathscribe/Kinematics.html");
        floatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                webView.scrollTo(0, 0);
            }
        });
        navigationView.setNavigationItemSelectedListener(this);
        DataBaseHandler db = new DataBaseHandler(this);
        if (checkBox.isChecked()) {
            db.add_activity(this.getClass().getSimpleName());

        }


    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (phy_law_toggel.onOptionsItemSelected(item)) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        int id = item.getItemId();
        if (id == R.id.favourite) {
            startActivity(new Intent(getApplicationContext(), FavoritePage.class));
        }
        drawerLayout.closeDrawer(GravityCompat.START);
        return true;
    }


    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (checkBox.isChecked()) {
            Toast.makeText(getApplicationContext(), " checked",
                    Toast.LENGTH_LONG).show();
            saveInSp("checkbox", isChecked);
        } else if (!checkBox.isChecked()) {
            Toast.makeText(getApplicationContext(), "not checked",
                    Toast.LENGTH_LONG).show();
            saveInSp("checkbox", !isChecked);
        }

    }

    private boolean getAsp(String key) {
        SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("ALpit", android.content.Context.MODE_PRIVATE);
        return sharedPreferences.getBoolean(key, false);
    }

    private void saveInSp(String key, boolean value) {
        SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences("ALpit", android.content.Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putBoolean(key, value);
        editor.apply();
    }


}




uncheck all check boxes other then one when clicked on a particular checkbox

I am working on checkboxes. Say I have three checkboxes:

<input type="checkbox" class="otherCheckboxes" id="checkbox1" value="1" /> 1
<input type="checkbox" class="otherCheckboxes"  id="checkbox2" value="2" /> 2
<input type="checkbox" id="checkbox3" value="No Entry" /> No Entry

Now if i check "No Entry" check box other checkboxes should be disabled if they are checked. And if i check again on other checkboxes when "No Entry" is checked, No Entry should be unchecked. i am trying to implement this using javascript and jquery.

i have tried:

$('#checkbox3').click(function() {
if ($(this).is(':checked')) {
    $('.otherCheckboxes').attr('checked', false);
} 

but this is not functioning according to the above requirement. Need some help resolving this issue Please. thanks in advance.




What is the right way to implement multiple checkboxes?

My project is Angular 2 + Rails API and I need to use multiple checkboxes.

I created has_and_belongs_to_many association for User and Pet models. Then I created an array of checkboxes on frontend and displayed it, for example:

dog

cat

parrot

After user checks some options, I then send those to the server and these values persist in the join table.

My question - is this the right way of implementing multiple checkboxes?




Checkbox causes infinite loop

So I'm making a program using html en Javascript where the user can click a button and the program will perform a calculation and a checkbox that when checked will perform that same calculation in a loop.

  <body>
  <button onclick="javascript:calc();"> Calculate</button>
  <form action="">
   <input id="checkbox" type='checkbox' name='auto' value='Auto' /> 
  </form>

   <script>
    var checkbox = document.getElementById('checkbox');
   function calc() {
     do{
    //Calculate stuff
     }while(checkbox.checked);
    }
   </script>

   </body>

Problem is that when I check the checkbox the webpage just freezes because it is stuck in an infinite loop so I can't uncheck the checkbox to stop it.

Is there any way to stop it from going into an infinite loop?




I want to update category of checked row in grid view, but it is giving the following error

Value of type 'System.Web.UI.Control' cannot be converted to 'System.Windows.Forms.CheckBox'

Here is the code:

Protected Sub btnMigrate_Click(sender As Object, e As EventArgs) Handles btnMigrate.Click
        Dim i As Integer
    For Each row As GridViewRow In GridView1.Rows
        If row.RowType = DataControlRowType.DataRow Then
                'If GridView1.GetType().Name = "chkbox" Then
                Dim chkRow As CheckBox = TryCast(row.Cells(5).FindControl("chkbox"), CheckBox)

            If chkRow.Checked Then
                Dim compid As String = row.Cells(0).Text
                Dim con As New SqlConnection("Data Source=DESKTOP-aiu042b;Initial Catalog=Municipal Corporation;Integrated Security=True")
                con.Open()
                Dim str As String = "update Complaint_info set c_category=@c where Category=@ct and complaint_id=@cid"
                Dim cmd As New SqlCommand(str, con)
                cmd.Parameters.AddWithValue("@c", txtCategory.Text)
                cmd.Parameters.AddWithValue("@ct", "OTHER")
                cmd.Parameters.AddWithValue("@cid", compid)
                i = cmd.ExecuteNonQuery
            End If
            ' End If
        End If
    Next

    If i > 1 Then
        MessageBox.Show("Records migrated to category " + txtCategory.Text)
    End If

End Sub




Values from checked checkboxes insert into database

I nedd help. I have form with 5 checkboxes and I need these values (when someone mark it) into one cell in database. Right now when you chceck some checkboxes, always send only value of last checkbox in code.

HTML:

<label class="dieta"><input type="checkbox" name="dieta[]" value="Vegertarian">Vegetarian</label>
<label class="dieta"><input type="checkbox" name="dieta[]" value="Vegan">Vegan</label>
<label class="dieta"><input type="checkbox" name="dieta[]" value="Bezlepku">Bez lepku</label>
<label class="dieta"><input type="checkbox" name="dieta[]" value="Bezlaktozy">Bez laktózy</label>
<label class="dieta"><input type="checkbox" name="dieta[]" value="Hindu">Hindu</label>

(Bad code) PHP:

$dieta = $_POST['dieta'];
require_once 'pripoj.php';
mysqli_query ($link, "INSERT INTO `d156881_tomas`.`svatba` (`dieta`,  `ID`) VALUES ('$dieta', NULL);");

Thanks so much if you let me know how to do.




Is there md-checkbox multiple selection available in angular2 Material?

Ive checked the documentation, but alas I have not been fortunate to reach to my desired destination.

I have a table of rows. In each row I have a md-checkbox, and I can select which is good. But I want to provide the functionality that that user should be able to select multiple checkboxes between the two selected checkboxes. From example, if I select the top checkbox, and I select the bottom checkbox, everything between them should be selected. This is very similar to gmail multiple selection.

enter image description here

Something like this.

Is this possible to do with md-checkbox in angular2?

If so, please enlighten me, and the fellow SO community.

Thanks!




samedi 25 février 2017

change select tags by choosing first and check a checkbox

I have dynamic number of select tag and a checkbox all i need is a simple javascript code when i change the first select tag and check the checkbox all other selected will change to the same as the first tag

<input type="checkbox" id="mycheck">
<select id="first">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
<select id="second">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
<select id="third">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
<select id="fourth">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>

when i change the first select and check the checkbox the other select changes to the same as first select thanks inadvance




How to Save Multiple Checkbox Values to a Database in Rails?

My app is a client on Angular 2 + Rails API and I would like to know how to save multiple checkbox values to a database.

For example, I have a form on html, in this form there are a bunch of checkboxes, the values of which I want to persist to a database. How do I go about handling this scenario?

I know how to do it using Rails templates, but have no idea how to implement it in Angular 2.

Thank you in advance.




How to add multiple tags (array) to a single post using jsp and mysql?

I have a problem
Tecno are the tags: java,php,javascript
my Recoge_datos.jsp

String[] tecno=request.getParameterValues("tecno");
try{

java.sql.Connection miConexion=java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/proyecto_jsp","root","");
java.sql.Statement miStatement=miConexion.createStatement();

String instruccionSql="INSERT INTO USERS (nombre, apellido, usuario, contra, pais, tecno) VAlUES ('" + nombre + "','" + apellido +"','"+ usuario +"','"+ contra +"','" + pais +"','" + tecno + "')";

miStatement.executeUpdate(instruccionSql);

out.println(" Registrado con exito ");
}catch(Exception e){
out.println("Ha habido un error");
}

and my formulario_registro.html

<form action="Recoge_datos.jsp" method="post">
<tr>
  <td>Tecnologias: </td>
  <td><label>
    <input type="checkbox" name="tecno" value="Java" id="tecnologias_0">
    Java</label>
    <br>
    <label>
      <input type="checkbox" name="tecno" value="PHP" id="tecnologias_1">
      Php</label>
    <br>
    <label>
      <input type="checkbox" name="tecno" value="JavaScript" id="tecnologias_2">
  JavaScript</label></td>
</tr>

In MySQL I have this: [Ljava.lang.String;@6ecf7e94
But it should be java,javascript,php If they were selected
I use the latest version of java and tomcat 9, all the latest version 02/2017




Woocommerce coupons adding custom checkbox

So I'm trying to figure out how I can add a function in functions.php to add a custom checkbox for coupons in woocommerce. I have a separat function for showing revenue on coupons, however, I'd like to add a checkbox on coupons, that allow me to look for that value in my coupon revenue so I can have only the coupons that have the checkobox checked show up in the drop-down list that allows me to select which coupon to view.

I've tried a bunch of things, nothing is working.

  1. because I can't figure out what the filter or action is to append to the existing coupon general tab

  2. I don't know how to get what I need in there.

    function add_coupon_list_checkbox( $post, $post_id, $include_stats ) {
    woocommerce_wp_checkbox( array( 'id' => 'include_stats', 'label' => __( 'Coupon check list', 'woocommerce' ), 'description' => sprintf( __( 'Includes the coupon in coupon check drop-down list', 'woocommerce' ) ) ) );
    $include_stats = isset( $_POST['include_stats'] ) ? 'yes' : 'no';
    update_post_meta( $post_id, 'include_stats', $include_stats );
    }add_filter( 'woocommerce_coupon_data' , 'add_coupon_list_checkbox' );
    
    

This is just something I tried. I looked at the wp-content/plugins/woocommerce/includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php. Entering the individual lines in there from my function works just fine. But I can't figure out how to hook in the the coupon from functions.php and set the custom checkbox from there, since I don't want to edit core files (for obvious reasons).




Changing group view in ExpandableListView

I have an ExpandableListView, it has checkboxes in the groups and in the childs. The checkbox in the group should be full when all it's childs are checked.

It works at the beginning when the activity first start, but if for example all of a group's childs are checked and it's checked too, and then I uncheck one of it's child - it won't uncheck.

I tried to write down that code in the getGroupView method, the same way I controlled the checkbox in each child through the getChildView method.

Where should I change the group's view after the activity has already started?

The code looks like this:

@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
    final String childText = (String) getChild(groupPosition, childPosition);
    final Boolean childIsWatched = (Boolean) getCheckedParameterChild(groupPosition, childPosition);

    if (convertView == null) {
        LayoutInflater infalInflater = (LayoutInflater) this.mContext
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = infalInflater.inflate(R.layout.expandable_list_item_watched, null);
    }

    // Set episode's name and checkbox
    ((TextView) convertView.findViewById(R.id.list_item_header)).setText(childText);
    final CheckBox checkBox = (CheckBox) convertView.findViewById(R.id.check_box_item);
    checkBox.setChecked(childIsWatched);

    // It had to be final to be inside the checkBox.setOnClickListener method
    final View finalConvertView = convertView;

    // Set checkbox press
    checkBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Get the new check value
            boolean newIsWatched = checkBox.isChecked();

            // Change episode in DB
            Model.getInstance().ChangeIsWatchedForEpisode(mContext,
                    mSeries.getId(),
                    Integer.toString(groupPosition + 1),
                    Integer.toString(childPosition + 1),
                    newIsWatched);

            // Change the adapter
            updateIsSeenValue(Integer.toString(groupPosition + 1),
                    Integer.toString(childPosition + 1),
                    newIsWatched);

            // Notify that there was a change
            notifyDataSetChanged();
        }
    });

    return convertView;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    // Set the group from the general ExpandableListAdapter
    View newConvertView = super.getGroupView(groupPosition, isExpanded, convertView, parent);

    // Set the group's checkboxes
    this.setGroupCheckbox(groupPosition, newConvertView);

    return newConvertView;
}




Making a check box buttom in a recyclerListView with an array list when it's Checked an aray list is append with a new object from the array list?

I am actually working in an application which shows in a section different cards with a check box that allow user to add this card to another activity which called favorites . i work with an adapter class which contain the check box button how can i do that




How to select check boxes on load page

I am trying to select some of these check boxes on load. I need to be able to select and unselect all check boxes after the page is loaded. So far I tried :$scope.itemSelected = [{ "ItemID": 1, "ItemName": "Item 1" }];

        div ng-repeat="item in itemItems">
            <md-checkbox ng-checked="existsItem(item, itemSelected);" ng-click="toggleItem(item, itemSelected);" value="">
                
            </md-checkbox>
        </div>

angular.module('MyApp', ['ngMaterial'])
.controller('AdminController', function ($scope) {

$scope.itemItems = [{ "ItemID": 1, "ItemName": "Item 1" }, { "ItemID": 2, "ItemName": "Item 2" },
    { "ItemID": 3, "ItemName": "Item 3" }, { "ItemID": 4, "ItemName": "Item 4" },
    { "ItemID": 5, "ItemName": "Item 5" }];
$scope.itemSelected = [];

$scope.toggleItem = function (item, list) {
    var idx = list.indexOf(item);
    if (idx > -1) {
        list.splice(idx, 1);
    }
    else {
        list.push(item);
    }
};

$scope.existsItem = function (item, list) {
    return list.indexOf(item) > -1;
};
})




Disable the rest of the checkboxes in a groupbox if I already selected two checkboxes?

 Private Sub AllBoxes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged, CheckBox2.CheckedChanged, CheckBox3.CheckedChanged, CheckBox4.CheckedChanged, CheckBox5.CheckedChanged, CheckBox6.CheckedChanged

    Dim qty As Int16 = 0
    Dim cb As CheckBox


    For Each cb In GroupBox8.Controls.OfType(Of CheckBox)
        If cb.Checked Then
            qty += 1
        End If
    Next

    If qty = 2 Then

        For Each cb In GroupBox8.Controls.OfType(Of CheckBox)
            If Not cb.Checked Then
                cb.Enabled = False
            End If
        Next
    Else

        For Each cb In GroupBox8.Controls.OfType(Of CheckBox)
            cb.Enabled = True
        Next
    End If
End Sub

it just doesn't work. The groupbox's name is groupbox8 and it has 6 checkboxes on it. I need to select two checkboxes.




Php : How can I make values that have been saved in a table appear on the page as being checked?

I have a table in my app, contacts, where a user (user_id) has a list of contacts :

contact_auto_inc      user_id       contact_id
17                       2             7
18                       2             8
19                       2             9

I show these contacts, their corresponding names, with this code :

<form action="" method="POST">

        <?php

         //this code below will get the username of contacts
         // for $user_id. we get the 'contact_id'
         //values in the contacts table for $user_id, match those contact_ids to    the corresponding 
         //'user_ids' in the user table, and then show the 'usernames' for each of those user_ids
           $select_from_user_table = "SELECT  contacts.contact_id, user.username
         FROM contacts 
         INNER JOIN user
         ON contacts.contact_id=user.user_id WHERE contacts.user_id = '$user_id'";

        //get the result of the above
         $result2=mysqli_query($con,$select_from_user_table);

    //show the usernames, phone numbers
         while($row = mysqli_fetch_assoc($result2)) { ?>
         <input type='checkbox' name='check_contacts[]' value='<?=$row['contact_id']?>'> <?php echo $row['username'] ?> </br>

        <?php   
        //we need the php bracket below to close the while loop

        }

            ?>

    <!--<input type="submit" name = "create" value = "Create new Contact"></p> -->

    <!--</form> -->

<p><input type="submit" name = "Save" value = "Save"></p>
<p><input type="submit" name = "Delete" value = "Delete"></p>
<a href="exit.php">Exit</a>
</form>

</body>
</html>

So it looks like this :

image.

And if one of the boxes is checked and then saved that contact gets saved to a review_shared table like this :

<?php
//here we want to save the checked contacts to the review_shared table ;  that is,
//who the user wants to share reviews with
if(!empty($_POST['check_contacts'])) {
    foreach($_POST['check_contacts'] as $check) {

    $insert_review_shared_command = "INSERT INTO review_shared VALUES(NULL," .$_GET['id']. ", '$user_id','$check')";

        //we want to save the checked contacts into the review_shared table
        $insert_into_review_shared_table = mysqli_query($con,$insert_review_shared_command);

    }

}

    $con->close();


    ?> 

But whenever I go back to the page, I still see :

enter image description here

How would I show contacts from the contacts table that are also in the review_shared table with a check in the corresponding check box ?




vendredi 24 février 2017

Enable/disable features with checkbox in Expandable List View

I was wondering if I could enable/disable a feature (activated using android:key) because I am using checkboxes inside an Expandable List View, which I am then settings as a resource file to use as a preference screen. is it possible to do this?




Why do I have the alert: "Undefined index" on PHP? I checked everything [duplicate]

I've been working in this php site. I was developing a form, but i can't send the data. It only appears:

( ! ) Notice: Undefined index: checkbox-2 in C:\wamp\www\Impre3D\es\publishpbd.php on line 19
Call Stack  

( ! ) Notice: Undefined index: checkbox-3 in C:\wamp\www\Impre3D\es\publishpbd.php on line 19
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 28
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 29
Call Stack  

( ! ) Notice: Undefined index: checkbox-1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 31
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-2 in C:\wamp\www\Impre3D\es\publishpbd.php on line 38
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-3 in C:\wamp\www\Impre3D\es\publishpbd.php on line 45
Call Stack  
01608
( ! ) Notice: Undefined index: checkbox-5 in C:\wamp\www\Impre3D\es\publishpbd.php on line 59
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-6 in C:\wamp\www\Impre3D\es\publishpbd.php on line 66
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-7 in C:\wamp\www\Impre3D\es\publishpbd.php on line 71
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-8 in C:\wamp\www\Impre3D\es\publishpbd.php on line 78
Call Stack  
0
( ! ) Notice: Undefined index: checkbox-9 in C:\wamp\www\Impre3D\es\publishpbd.php on line 83
Call Stack  
01805
( ! ) Notice: Undefined index: checkbox-11 in C:\wamp\www\Impre3D\es\publishpbd.php on line 95
Call Stack  
0
( ! ) Notice: Undefined index: category in C:\wamp\www\Impre3D\es\publishpbd.php on line 104
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 107
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 108
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 109
Call Stack  

( ! ) Notice: Undefined index: files in C:\wamp\www\Impre3D\es\publishpbd.php on line 111
Call Stack  

( ! ) Notice: Undefined index: files in C:\wamp\www\Impre3D\es\publishpbd.php on line 112
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 113
Call Stack  

( ! ) Notice: Undefined index: files1 in C:\wamp\www\Impre3D\es\publishpbd.php on line 114

This is my code, I hope you can help me: //HTML

<form method="POST" action="publishpbd.php" name="uploadprinter" id="uploadprinter" enctype="multipart/form-data">
        <label for="strName" class='label-sign' style="font-size:25px;" >Crear centro de impresión 3D</label>
            <div style='margin:5px;color:#f92859;font-size:12px;'>&nbsp;&nbsp;* campo obligatorio</div>
              <label for="strName" class='label-sign'> *Nombre del print hub:</label>
              <input type="text" name="strName" id="strName" class="input-text" autocomplete="off" maxlength="50" required>
        <label for="" class='label-sign'> *Materiales tratados:</label>      
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-1" name="checkbox-1" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">ABS</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-2" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-2" name="checkbox-2" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">PLA</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-3" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-3" name="checkbox-3" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">Nylon</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-4" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-4" name="checkbox-4" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">HIPS</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-5" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-5" name="checkbox-5" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">PET</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-6" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-6" name="checkbox-6" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">LAYWOOD-D3</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-7" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-7" name="checkbox-7" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">NINJAFLEX</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-8" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-8" name="checkbox-8" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">METAL</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-9" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-9" name="checkbox-9" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">LAYBRICK</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-10" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-10" name="checkbox-10" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">SOFTPLA</span><br>
          </label>
          <label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-11" style="margin-left: 20px;">
          <input type="checkbox" value="1" id="checkbox-11" name="checkbox-11" class="mdl-checkbox__input" onchange="javascript:showContent()">
          <span class="mdl-checkbox__label">BENDLAY</span><br>
          </label>
        </label>
              <div style="display: none;" id="abs">
        <center><h4>ABS</h4></center>
        <label for="abs" class='label-sign'> Precio por hora del ABS(dólares estadounidenses):</label>
              <input type="number" value="0" name="input-abs" id="input-abs" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-1" class='label-sign'> Colores disponibles:</label>
        <select name="color-1" id="color-1" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="pla">
        <center><h4>PLA</h4></center>
        <label for="pla" class='label-sign'> Precio por hora del PLA(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-pla" id="input-pla" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-2" class='label-sign'> Colores disponibles:</label>
        <select name="color-2" id="color-2" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="nylon">
        <center><h4>NYLON</h4></center>
        <label for="nylon" class='label-sign'> Precio por hora del Nylon(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-nylon" id="input-nylon" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-3" class='label-sign'> Colores disponibles:</label>
        <select name="color-3" id="color-3" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="pet">
        <center><h4>PET</h4></center>
        <label for="pet" class='label-sign'> Precio por hora del PET(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-pet" id="input-pet" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-4" class='label-sign'> Colores disponibles:</label>
        <select name="color-4" id="color-4" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="hips">
        <center><h4>HIPS</h4></center>
        <label for="hips" class='label-sign'> Precio por hora del HIPS(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-hips" id="input-hips" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-5" class='label-sign'> Colores disponibles:</label>
        <select name="color-5" id="color-5" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="laywood-d3">
        <center><h4>LAYWOOD-D3</h4></center>
        <label for="laywood-d3" class='label-sign'> Precio por hora del LAYWOOD-D3 (dólares estadounidenses):</label>
        <input type="number" value="0" name="input-laywood-d3" id="input-laywood-d3" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <div style="display: none;" id="ninjaflex">
        <center><h4>NINJAFLEX</h4></center>
        <label for="ninjaflex" class='label-sign'> Precio por hora del NINJAFLEX(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-ninjaflex" id="input-ninjaflex" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-6" class='label-sign'> Colores disponibles:</label>
        <select name="color-6" id="color-6" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="metal">
        <center><h4>Metal</h4></center>
        <label for="metal" class='label-sign'> Precio por hora del Metal(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-metal" id="input-metal" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <div style="display: none;" id="laybrick">
        <center><h4>Laybrick</h4></center>
        <label for="laybrick" class='label-sign'> Precio por hora del Laybrick(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-laybrick" id="input-laybrick" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <div style="display: none;" id="softpla">
        <center><h4>SoftPla</h4></center>
        <label for="softpla" class='label-sign'> Precio por hora del SoftPla(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-softpla" id="input-softpla" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        <label for="color-7" class='label-sign'> Colores disponibles:</label>
        <select name="color-7" id="color-7" class="input-text">
          <option value="">Selecciona un color</option>
          <option value="1">Blanco</option>
          <option value="2">Negro</option>
          <option value="3">Rojo</option>
          <option value="4">Amarillo</option>
          <option value="5">Verde</option>
          <option value="6">Azul</option>
          <option value="7">Naranja</option>
          <option value="8">Rosado</option>
          <option value="9">Morado</option>
          <option value="10">Gris</option>
          <option value="11">Celeste</option>
        </select>
        </div>

        <div style="display: none;" id="bendlay">
        <center><h4>Bendlay</h4></center>
        <label for="bendlay" class='label-sign'> Precio por hora del Bendlay(dólares estadounidenses):</label>
        <input type="number" value="0" name="input-bendlay" id="input-bendlay" class="input-text" autocomplete="off" min="0" step="10" max="500" required>
        </div>

        <label for="strBDesc" class='label-sign'> Descripción básica:<p style='font-weight: lighter;font-size:12px;'>(Hasta 200 caracteres)</p></label>
        <textarea name="strBDesc" id="strBDesc" class="input-text" autocomplete="off" maxlength="200"></textarea>       
        <label for="strADesc" class='label-sign'> Descripción avanzada:<p style='font-weight: lighter;font-size:12px;'>(Hasta 600 caracteres)</p></label>
        <textarea name="strADesc" id="strADesc" class="input-text" autocomplete="off" min="0" maxlength="600"> </textarea>
        <input type="hidden" name="MAX_FILE_SIZE" value="4194304" />            
        <br><label for="country" class='label-sign'> *País:</label><br>
          <select name="country" required autocomplete="off" class="input-text">
              <option value=""></option>
        <option value="00">example</option>
        <option value="00">example</option>
      </select>
      <br><label for="strAdress" class='label-sign'> *Domicilio:</label>
      <input type="text" name="strAdress" id="strAdress" autocomplete="off" class="input-text" required>

              <label for="files1" class='label-sign'> Subir imágen:</label>
              <input type="file" name="files1" id="files1" class="input-text" accept="image/*">
        <a id="btn-reset">
        <output id="list"></output>
        </a>
              <br><br>
              <center>
                <input type="submit" name="submit" id="submit" value="Publicar diseño 3D" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
              </center>
     </form>`
**//PHP publishpbd.php**
<?php require_once('../conection/conection.php');
if(isset($_POST['submit'])){
if(isset($_POST['checkbox-1'])||($_POST['checkbox-2'])||($_POST['checkbox-3'])|| ($_POST['checkbox-4'])||($_POST['checkbox-5'])||($_POST['checkbox-6'])||($_POST['checkbox-7'])||($_POST['checkbox-8'])||($_POST['checkbox-9'])||($_POST['checkbox-10'])||($_POST['checkbox-11'])){
$id=($_SESSION["Id"]);
$correo=($_SESSION["Email"]);
//CAMPOS
$nombre=($_POST['strName']);
$basicdescription=($_POST['strBDesc']);
$advanceddescription=($_POST['strADesc']);
$country=($_POST['country']);
$adress=($_POST['strAdress']);
$file=($_FILES['files1']['tmp_name']);
$filesize=($_FILES['files1']['size']);
//
$abs=($_POST['checkbox-1']);
$absinput=($_POST['input-abs']);
$abscolor=($_POST['color-1']);
print_r($abs);
print_r($absinput);
print_r($abscolor);
//
$pla=($_POST['checkbox-2']);
$plainput=($_POST['input-pla']);
$placolor=($_POST['color-2']);
print_r($pla);
print_r($plainput);
print_r($placolor);
//
$nylon=($_POST['checkbox-3']);
$nyloninput=($_POST['input-nylon']);
$nyloncolor=($_POST['color-3']);
print_r($nylon);
print_r($nyloninput);
print_r($nyloncolor);
//
$hips=($_POST['checkbox-4']);
$hipsinput=($_POST['input-hips']);
$hipscolor=($_POST['color-5']);
print_r($hips);
print_r($hipsinput);
print_r($hipscolor);
//
$pet=($_POST['checkbox-5']);
$petinput=($_POST['input-pet']);
$petcolor=($_POST['color-4']);
print_r($pet);
print_r($petinput);
print_r($petcolor);
//
$laywoodd3=($_POST['checkbox-6']);
$laywoodd3input=($_POST['input-laywood-d3']);
print_r($laywoodd3);
print_r($laywoodd3input);
//
$ninjaflex=($_POST['checkbox-7']);
$ninjaflexinput=($_POST['input-ninjaflex']);
$ninjaflexcolor=($_POST['color-6']);
print_r($ninjaflex);
print_r($ninjaflexinput);
print_r($ninjaflexcolor);
//
$metal=($_POST['checkbox-8']);
$metalinput=($_POST['input-metal']);
print_r($metal);
print_r($metalinput);
//
$laybrick=($_POST['checkbox-9']);
$laybrickinput=($_POST['input-laybrick']);
print_r($laybrick);
print_r($laybrickinput);
//
$softpla=($_POST['checkbox-10']);
$softplainput=($_POST['input-softpla']);
$softplacolor=($_POST['color-7']);
print_r($softpla);
print_r($softplainput);
print_r($softplacolor);
//
$bendlay=($_POST['checkbox-11']);
$bendlayinput=($_POST['input-bendlay']);
print_r($bendlay);
print_r($bendlayinput);
//SESSION
$name=$_SESSION['Name'];
$lastname=$_SESSION['LastName'];
$bdesc=$_POST['strBDesc'];
$adesc=$_POST['strADesc'];
$cat=$_POST['category'];
$nombred=$name." ".$lastname;
$timestamp = date("Y-m-d");
$name1 = $_FILES["files1"]["name"];
$size1 = $_FILES['files1']['size'];
$type1 = $_FILES['files1']['type'];

$tmp_name = $_FILES['files']['tmp_name'];
$error = $_FILES['files']['error'];
$tmp_name1 = $_FILES['files1']['tmp_name'];
$error1 = $_FILES['files1']['error'];
}else{
  ?>
  <script>
    alert("No has seleccionado ningun checkbox");
    window.location="dashboard.php";
  </script>
  <?php 
}
}else{
  ?>
  <script>
    alert("Ha ocurrido un problema, por favor vuelve a intentarlo");
    window.location="dashboard.php";
  </script>
  <?php 
}
?>

Thank you!