vendredi 30 novembre 2018

How to change checkbox value with AutoItX 3?

I am working on a script that needs to change the value of Win32's Checkbox control using AutoItX 3 (the DLL/COM library of AutoIt3.)

This seems to be a common problem with the checkbox value in AutoIt, and this answer seems to have a solution for .au3 scripts, but I need a solution that works with AutoItX.

Do you have any suggestions?




How to get Checkbox value in ruby on rails

I want to get checkboxs values in order to set parameters of an http request to a restful API. I am new to web development and I am having troubles with ruby on rails 5.1

Basically, I have two views: - one where you can check/uncheck two checkboxs and then press a button which makes some API calls and send you to the second view. - the second is just for displaying the API informations.

In the first view, I succeed to do the button that "makes" the API call, and the API informations are correctly displayed in the second. I now have trouble to add parameters, with the two checkboxs, to the request. My checkboxs are always returning me "nil" in params[].

I referred to this section of the rails doc: https://guides.rubyonrails.org/form_helpers.html#helpers-for-generating-form-elements and to several other stackoverflow questions without understanding what I missed.

here is the controller code:

class IndexController < ApplicationController
  include HTTParty

  def button_state
  end

  def display_state
    require 'open-uri'
    require 'json'

    # this part is for checking my checkbox values, they are always nil

    @t1 =  params[:param_name1]
    @t2 =  params[:param_name2]
    @url_test = 'www.bkbahbqiv.com/tamere?test1=' << @t1.to_s << '&test2=' << @t2.to_s

    # other part related to the API calls
    ...
  end
end

and here is my view code:

<h1>Check/Uncheck the boxes and click on the button to get results</h1>
<div class="checkbox">
  <td>
  <%= label_tag(:param_name1, "test1") %>
  <%= check_box_tag(:param_name1) %>
  </td>
</div>
<div class="checkbox">
  <td>
  <%= label_tag(:param_name2, "test2") %>
  <%=  check_box_tag(:param_name2) %>
  </td>
</div>

<%= button_to "go to display_state", display_state_path, :method => :get %>

I will just add that I don't want to store the checkbox values in a database.

Thanks in advance for anyone helping me :)




How do I set a default value on a checkbox in Angular?

I have the following code:

< input type="checkbox" [(ngModel)]="i.checkt" [ngModelOptions]={standalone:true} (change)="recovery(i.checkt,i.TherapeuticArea)">

The problem I am facing is that with standalone:true every checkbox is checked by default and when standalone is false, the checkbox isn't working. Is there any way of setting the checkbox value to unchecked while having full functionality?




How to make a double loop to populate an echo statement

I have values written in a database. These value come from a checkbox form.
I try to get these values from the database and write them in a new page.
I use the following code that works :

$con = pg_connect("host=$host port=$port dbname=$dbname user=$user password=$pw") or die ("Error in Selecting ");

    $sql = pg_query($con,"SELECT language FROM texte where bhl='17'");
    if(pg_num_rows($sql) > 0){
      $result = pg_fetch_assoc($sql);
      $checked_arr = explode(";",$result['language']);
    }
    // Gives "item1"

    // Create checkboxes
    foreach ($checked_arr as &$value) { 
        $array1 = array("item1", "item2", "item3");
        $id = array("id-item1", "id-item2", "id-item3");
          $checked = "";
          if(in_array($value, $array1)){
            $checked = "checked";
          }
          echo '<input type="checkbox" name="lang[]" value="'.$value.'" '.$checked.' > '.$value.' <br/>';
    }

But actually something is missing : the id value that characterizes the checkbox. So I inserted in the code an array composed of the id values.
The goal is to associate id-item1 to item1, id-item2 to item 2 and so on.
To make it possible I guess I have to create a double loop to write in the echo statement both values and id's.
But after many attempts I didn't manage to make it possible.

Any help would be appreciated.
Thanks !




jeudi 29 novembre 2018

laravel mysql database same page multiple form submission table not updating

i am trying to update database table by using checkboxes ,the code is not giving any error,but the database table is not updating. My blade code where the form is:

<body>
        <h2>Reported Posts </h2>
        <a href="">Back</a> 

        <table>
        @foreach($post_reports as $post_report)
            <tr>
                <td>Report NO:</td>
                <td></td>
                <td></td>
    <form method="post">
        @csrf
                <td><input type="checkbox" name="statusyes[]" value= >report to admin  <input type="checkbox" name="statusno[]" value= >wrong report </td>
            </tr>
        @endforeach
        <td><input type="submit" name="submit" value="Submit" /></td>
    </form>
        </table>

my controller code is :

I am using the status_update_reported_post function

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Post_report;
use Illuminate\Support\Facades\DB;


class moderatorController extends Controller
{
    public function index(Request $request){

    return view('moderator.index');
   }

   public function reported_post(Request $request){

    $post_reports=DB::table('Post_reports')
                ->where('status','moderator')->get();

    return view('moderator.reported_post')-> with('post_reports',$post_reports);
   }

   public function status_update_reported_post(Request $request){
   $statusadmin[]=$request['statusyes'];
   $statuswrong[]=$request['statusno'];
   $r='admin';
   $wr='wrong';

   foreach($statusadmin as $report_id){
      DB::table('post_reports')
               ->where('report_id','$report_id')
               ->update(['status' => 'admin']);

   }

   foreach($statuswrong as $report_id){

        DB::table('post_reports')
               ->where('report_id','$report_id')
               ->update(['status' => 'wrong']);

   }
}


}

the code is working fine but there is no update in the table i dont know where the problem is, It all seems fine to me .




c# wpf listview checkbox item

I realize Listview for the photo preview.

<xctk:MaterialListBox InkEffectBrush="CornflowerBlue"  IsInkEffectActive="True" Background="Transparent" x:Name="TvBox" ScrollBar.Scroll="TvBox_Scroll" ScrollViewer.ScrollChanged="TvBox_ScrollChanged" GiveFeedback="TvBox_GiveFeedback"  AllowDrop="False" PreviewMouseLeftButtonDown="TvBox_PreviewMouseLeftButtonDown" PreviewMouseMove="TvBox_PreviewMouseMove" Margin="0,0,0,10" HorizontalAlignment="Stretch">
            <xctk:MaterialListBox.ItemContainerStyle>
                <Style TargetType="{x:Type xctk:MaterialListBoxItem}">
                    <Setter Property="Height" Value="100" />
                    <Setter Property="VerticalAlignment" Value="Top" />
                </Style>
            </xctk:MaterialListBox.ItemContainerStyle>
            <xctk:MaterialListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="4" Background="#00FFFFFF"/>
                </ItemsPanelTemplate>
            </xctk:MaterialListBox.ItemsPanel>
            <xctk:MaterialListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical" >
                        <Image Height="100" Width="200" Source="{Binding ImageData}"  Stretch="Uniform" />
                        <xctk:MaterialCheckBox Background="BlueViolet" Content="Выбрать" Click="MaterialButton_Click" HorizontalAlignment="Center" Height="35" Margin="0,20" Width="130"/>
                    </StackPanel>
                </DataTemplate>
            </xctk:MaterialListBox.ItemTemplate>
        </xctk:MaterialListBox> 

Screnshoot Listview. I need a checkbox on top of the image. Example as needed Prompt please solve this problem. Thank you in advance.




In C#, implement a check box to control the display of a message box when deleting a record from database

I am having trouble implementing a check box that when checked will make a message box pop up when the user is trying to delete a record. When the check box is unchecked, the message box will not pop up and the record will be deleted right away.

Here is what I have currently without the checkbox implementation.

private void deleteButton_Click(object sender, EventArgs e)
{
    try
    {
      int index = dataGridViewClients.CurrentRow.Index;
      if(MessageBox.Show("Do you want to delete record?", "Message", 
         MessageBoxButtons.YesNo)==DialogResult.Yes){
         ClientValidation.DeleteClient(clientVM.Clients[index]);
         }
     }
}

I am unsure how to put in the check box control within the method Any help is appreciated.




Nested Checkbox in Materialize

I am trying to make nested checkboxes with Materializejs. The problem is that when I check the outer checkbox when it is collapsed, the inner checkboxes are opened again. This is my code:

                <ul class="collapsible">
                    <li>
                        <div class="collapsible-header">
                            <i class="material-icons">arrow_drop_down</i>
                            <label>
                                <input type="checkbox" class="filled-in" />
                                <span>Filled in</span>
                            </label>
                        </div>
                        <div class="collapsible-body">
                            <i class="material-icons">arrow_drop_down</i>
                            <label>
                                <input type="checkbox" class="filled-in" />
                                <span>Filled in</span>
                            </label>
                        </div>
                    </li>
                </ul>


<script>
    document.addEventListener("DOMContentLoaded", function () {
        var elems = document.querySelectorAll(".collapsible");
        var instances = M.Collapsible.init(elems, {});
    });
</script>




Check a radio button dynamically in ionic 3

Hi Guys I have this Json Response below which I have consoled: JSON Response

I want to check/pre-select the ion-radio and ion-checkbox if the value of DEFAULT is equal to Y. I had no luck finding a solution. This are the files:

my html file

  <ion-list *ngFor = "let title of data" >
      <ion-row  radio-group name="radio" [(ngModel)]="sortby">
        <ion-item>
          <p></p>
        </ion-item> 
        <ion-col *ngIf = 'title.TYPE !== "INC";else checkb'>
          <div  *ngFor = "let customItems of title?.DET; let i = index;">
          <ion-item *ngIf = 'customItems.DEFAULT !== "Y";else redcheck'>

            <ion-label></ion-label>
            <ion-radio (ionSelect)="selectRad(customItems)" [value]="customItems"></ion-radio>

          </ion-item>
          <ng-template #redcheck>
              <ion-item>

                  <ion-label></ion-label>
                  <ion-radio (ionSelect)="selectRad(customItems)" [value]="customItems"  [checked]="i==0"></ion-radio>

                </ion-item>
          </ng-template>
        </div>
        </ion-col>
        <ng-template #checkb>
            <ion-col>
                <ion-item  *ngFor = "let customItems of title?.DET">
                    <ion-label></ion-label>
                    <ion-checkbox [(ngModel)]="customItems.checked" (ngModelChange)="selectCat(customItems,$event)"></ion-checkbox>
                </ion-item>
              </ion-col>
        </ng-template>
      </ion-row>
      <ion-buttons end>
        <button ion-button (click) = "submitCustomisation()">
          Save
        </button>
      </ion-buttons>
    </ion-list>

my ts file methods are

 submitCustomisation(){

    this.result=this.selectedArrayCust;

    this.resultRad = this.custValue;
    console.log("Vlue check",this.resultRad);
   console.log("checkstorage",this.result);
  }

  selectCat(data){
    if (data.checked == true) {
      this.gotta = this.selectedArrayCust.push(data)
       //localStorage.setItem('cuisinearray',this.gotta);
     } else {
      this.selectedArrayCust.pop(data)
      let newArray = this.selectedArrayCust.filter(function(el) {
        return el !== data;
     });
      this.selectedArrayCust = newArray;
    }
    console.log("From CheckBox",this.selectedArrayCust);
   }

   selectRad(data){
    console.log("Radio data",data);
    this.custValue = data;
 }

To make it more clear I have added a screenshot of the app App Screenshot. In this case Patal & Sukhi and Pav (2 pieces) have a DEFAULT value of Y and I want to select/check these two options.




mercredi 28 novembre 2018

Wildcard search for checkbox values don't work

for the checkbox value filter on this site https://www.test-site.ch/stackoverflow-sprachen.html I would like the user to find the value "Deutsch" in column1 not only if "Deutsch" is a single value, but also if "Deutsch" is part of the entire cell value.

Currently the check on "Deutsch" only shows 1 row, but 2 are actually expected.

this is the function embedded in the header section:

<script type="text/javascript" class="init">
$(function() {
  otable = $('#dt').dataTable();
})
function filterme() {
  //build a regex filter string with an or(|) 
condition
var types =$('input:checkbox[name="type"]
:checked').map(function() {
return '^' + this.value + '\$';
}).get().join('|');
//filter in column 0, with an regex, no smart 
filtering, no inputbox,not case sensitive
otable.fnFilter(types, 0, true, false, false, 
false);
}
</script>

Table content

<tbody>
  <tr>
  <td>Deutsch</td>
  <td>8156</td>
  <td>Dielsdorf</td>
  <td>Hans Muster</td>
  <td>Sekundarlehrer (pensioniert),
      4 Jahre Erfahrung</td>
   <td>30.--</td>
  </tr>
  <tr>
    <td>Italienisch Franz&ouml;sisch Deutsch </td>
    <td>8000</td>
    <td>Z&uuml;rich</td>
         <td>H. W&auml;ckerli </td>
              <td>Gymi Lehrer </td>
              <td>30.--</td>
  </tr>




Disable multiple check buttons if another check button is checked

Im learning javascript and Im just trying do something basic.

I have this:

example

I want disable checkboxes " box1, box2, box3 " if 'Cash' OR 'Square' OR 'Paypal' is checked.

I get disable them when I check 'Cash' but i can't figure out how do it with square and paypal boxes as well.

Here is the jsfiddle: http://jsfiddle.net/c9s1fuoL/




How to subscribe to checked/unchecked event for all checkboxes inside combobox?

I have a simple ComboBox with CheckBoxes as items. ComboBox has an item source binding to List of UserModel. The checkbox inside the ComboBox has events for checked/unchecked and has binding to isSelected Property of UserModel.

I also have button click subscribed to an event which edits data in UserModel. On the click of button appropriate checkboxes are getting checked/unchecked. While the checkboxes are checked/unchecked I also want the checkbox checked/unchecked event to be fired.

   <ComboBox x:Name="cmbUser" 
      ItemsSource="{Binding UserCollection}"
      SelectedValuePath="UserName"
      IsSynchronizedWithCurrentItem="True"
      TextSearch.TextPath="UserName">
                 <ComboBox.ItemTemplate >
                        <DataTemplate>
                                <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}" Checked="UpdateSelectedUsers" Unchecked="UpdateSelectedUsers">
                                    <StackPanel Orientation="Horizontal">
                                           <TextBlock Text="{Binding UserName}" Width="105"></TextBlock>
                                    </StackPanel>
                                </CheckBox>
                         </DataTemplate>
                </ComboBox.ItemTemplate>
   </ComboBox>

I see the events are only fired when I at least open the dropdown once. So all the checkboxes inside ComboBox are loaded and subscribed to checked/unchecked event handlers.

Is there any solution to subscribe all the checkboxes inside ComboBox on the load?




Yii2 Cannot insert/update more than 1000 checked rows

I am trying to insert/update more than 1000 selected/ checked rows and when I submit (POST) form my controller inserts/ updates the first 999 checked rows. I used var_dump($_POST) and it returns the first 999 rows. Any help Appreciated.




VueJs 2: map selected child checkboxes with the parent

I have multiple roles and their permissions (checkboxes). So now when I select some permissions from role I need to map these permissions to be associated with the their role.

JsFiddle

HTML:

<div id="app">
  <div v-for="role in roles" class="role-row" :key="role.id">
    <label></label>
    <hr>
    <div v-for="perm in role.perms" :key="perm.id">
      <input type="checkbox" :value="perm" v-model="checked_roles"> 
    </div>
  </div>

  <p>Selected roles and perms</p>
   // [ { "perm_id": 2, "perm_name": "Update" }, { "perm_id": 1, "perm_name": "Create" } ] 
</div>

VueJs:

new Vue({
  el: '#app',
  data: {
    checked_roles: [],
    roles: [
      {
        "role_id" : 1,
        "role_name" : 'Administrator',
        "perms" : [
            {
            "perm_id" : 1,
            "perm_name" : 'Create'
          },
          {
            "perm_id" : 2,
            'perm_name' : 'Update'
          },
          {
            "perm_id" : 3,
            'perm_name' : 'Delete'
          }
        ]
      },
      {
        "role_id" : 2,
        "role_name" : 'Moderator',
        "perms" : [
            {
            "perm_id" : 1,
            "perm_name" : 'Create'
          },
          {
            "perm_id" : 2,
            'perm_name' : 'Update'
          },
          {
            "perm_id" : 3,
            'perm_name' : 'Delete'
          }
        ]
      }
    ]
  }
})

Result: Here I'm getting selected checkboxes but also I need to map the role as a key

[ { "perm_id": 2, "perm_name": "Update" }, { "perm_id": 1, "perm_name": "Create" } ] 

Probably, I have to use computed property or watch method, but I'm new in the VueJs and I tried multiple times to resolve this, but without result.

if I pass: :value="{role, perm}" I'm getting the whole role object, but it's not the case here




Angular 4 select all checkboxes

i am trying to implement select all checkbox which will select all the checkboxes which is fine but when i click on other checkboxes other than select all it will again select all checkboxes

Html file

<div class="form-check mt-3">
      <label class="form-check-label text-dark font-weight-bold">
        <input class="form-check-input" type="checkbox" value="" [(ngModel)]="selectedAll" [ngModelOptions]="{standalone:

true}" (change)="selectAll()"> Select All

    <div  *ngFor="let a of name">

    <div class="d-flex justify-content-between">

      <!--------------------div to justify content --------------------->
      <div class="">

        <div class="form-check mt-3">
          <label class="form-check-label text-dark">
            <input class="form-check-input" type="checkbox" value="" [(ngModel)]="a.selected" [ngModelOptions]="{standalone:

true}" (change)="checkIfAllSelected()"> Household Information

        <div class="form-check mt-3">
          <label class="form-check-label text-dark">
            <input class="form-check-input" type="checkbox" value="" [(ngModel)]="a.selected" [ngModelOptions]="{standalone:

true}" (change)="checkIfAllSelected()"> House Images

        <div class="form-check mt-3" >
          <label class="form-check-label text-dark">
            <input class="form-check-input" type="checkbox" value="" [(ngModel)]="a.selected" [ngModelOptions]="{standalone:

true}" (change)="checkIfAllSelected()"> Map Access

Ts file

selectAll() {
for (let i = 0; i < this.name.length; i++) {
  {
    this.name[i].selected = this.selectedAll;
  }
}

}

checkIfAllSelected() {

console.log(this.name);

this.selectedAll = this.name.every(function (item: any) {
  console.log(item);
  return item.selected == true;
})

}




checkbox filter/search button: can't undo filtering when unchecked

I have a table made with datatables. There is checkbox, which, when clicked filters the table to display only the data I want to see. The problem is that when I uncheck the checkbox, the table becomes buggy. The table.destroy() function does seemingly revert the table back to the way it was, although it looks like it destroys a little too much (rows per page suddenly get ignored + can no longer click on cell, which opens up in another window).

This is what happens: 1. click on checkbox: filters the data correctly 2. uncheck checkbox: table looks as if gone back to normal (but hasn't really) 3. check checkbox again: no longer filters data correctly. (table is now empty) 4. now it doesn't matter if I check or uncheck, the table stays the same(empty)

Here is my code:

var checkbox = $("#checkB");
checkbox.click(function () {
     var table = $('#WTM_LOG').DataTable();
     if (checkbox.is(":checked")) {
            $.fn.dataTable.ext.search.push(
                function (settings, data, dataIndex) {
                    var num = Number(data[4]);
                    if (num > 0) {
                        return true;
                    }
                    return false;
                }
            );
            table.draw();
        }
    else {
            table.destroy();    
        }
    });




How to show all checked checkboxes also at reloading the page?

I have a problem: my website is searching for checked checkboxes with a javascript.

$(function () {
    var $allELements           = $('.input-box');
    var $selectedElementsListing = $('#selectedElements');
    var $selectedElementsLabel   = $('#selectedElementsLabel');
    var $elementInfo         = $('.elementInfo ');

    $allELements.on('click', function () {
        $selectedElementsListing .html(
            $allELements.filter(':checked').map(function (index, checkbox) {
                return '<div>' + checkbox.title + '</div>';
            }).get().join('')
        );

        if ($selectedElementsListing .text().trim().length)
        {
            $selectedElementsListing .show();
            $selectedElementsLabel.show();
            $elementInfo.show();
        }
    });
});

So it is searching for checked checkboxes on my main page and is listing the name of the checkboxes on the lower left hand side (as information for the user). My HTML looks like this:

<div class="elementInfo" >
        <p>
            <strong id="selectedElementsLabel" ><u>Ausgewählte
                Magazine:</u></strong><br />
            <span id="selectedElements"></span>
        </p>
</div>

And it takes the checkbox names from this input field:

<input class="input-box" title="[[ElementName]]" type="checkbox" id="A[[ID]]" name="ID[]"
                                       value="[[ID]]" checked="[[checked_element]]" />




Datatable Checkbox selection

Script:

<script type="text/javascript">
    $(document).ready(function(){
    $(".datepicker" ).datepicker({ dateFormat: 'dd/mm/yyyy' });
    $('#employeeId').chosen({no_results_text:'No Employees !'});
    $('#workScheduleId').chosen({no_results_text:'No Employees !'});

    });

    $(document).ready(function() {
        var oTable = $('#order-listing').dataTable( {
            initComplete: function () {
                this.api().columns().every( function () {
                    var column = this;
                    var select = $('<select><option value=""></option></select>')
                        .appendTo( $(column.footer()).empty() )
                        .on( 'change', function () {
                            var val = $.fn.dataTable.util.escapeRegex(
                                $(this).val()
                            );

                            column
                                .search( val ? '^'+val+'$' : '', true, false )
                                .draw();
                        } );

                    column.data().unique().sort().each( function ( d, j ) {
                        select.append( '<option value="'+d+'">'+d+'</option>' )
                    } );
                } );
            },
            columnDefs: [ {
                orderable: false,
                className: 'select-checkbox',
                targets:   0
            } ],
            select: {
                style:    'multi',
                selector: 'td:first-child'
            },
            lengthMenu: [[20,50, 100, -1], [20, 50, 100, "All"]],
            pageLength: 20 
         } );
        var allPages = oTable.fnGetNodes();

        $('body').on('click', '#selectAll', function () {
            if ($(this).hasClass('allChecked')) {
                $('input[type="checkbox"]', allPages).prop('checked', false);
            } else {
                $('input[type="checkbox"]', allPages).prop('checked', true);
            }
            $(this).toggleClass('allChecked');
        });



    } );

</script>

View:

<div class="code" id="code"> 
        <table id="order-listing" class="table">
            <thead>
                <tr class="bg-light">
                    <th><input type="checkbox" name="selectAll" id="selectAll" class="form-control" data-to-table="tasks" value=1></th>
                    <th>Code</th>
                    <th>Name</th>

                </tr>
            </thead>
            <tbody class="reportData">
                <?php
                    if(is_array($datas)){
                    foreach($datas as $data){
                ?>

                <tr>
                    <td class="a-center "><input type="checkbox" name="selectall[]" class="form-control" value="<?php echo $data['Id']; ?>"/></td>
                    <td><?php echo $data['Code'];?></td> 
                    <td><?php echo $data['Name'];?></td>

                </tr>
                <?php
                    }
                    }else{
                ?>
                <?php
                    }   
                ?>
            </tbody>

        </table>
    </div>
</div>
<div class="shift_category form-group">
    <button type="button" class="btn btn-default" data-dismiss="modal" >Close</button>
    <button type="submit" class="btn btn-primary">Submit</button>
</div>

Here is my datatable view & Script.When I select some values using checkbox from morethan one pages,Only the last page values are inserted into database.I want the values from all pages that i have selected.How to solve this issue.Please help me .....................................................................




mardi 27 novembre 2018

How to modify a string based on a checkbox array?

I have a function that have :
- Inputs : an array of Data

[{"position":"1","token":"Darién","tag":"PERSON"},{"position":"2","token":"Darién","tag":"PERSON"},{"position":"3","token":"Gap","tag":"PERSON"},{"position":"4","token":"Gap","tag":"PERSON"},{"position":"5","token":"make","tag":"O"}] 

I iterate that array to get the token and tag and then based on a checkbox selection (person or country ...etc) I make the token string red and show it in a div element.

 function makeNamesRed(array) {

        let result = ''

        array.forEach((element, index, array) => {
            var word = element.token;
            var tag = element.tag;

            var checkedElements = new Array();
            $("input:checkbox[name=selectionFilter]:checked").each(function () {
                checkedElements.push($(this).val());
            });

            checkedElements.forEach((element, index, array) => {

                if (word != "-LRB-" & word != "-RRB-") {

                    if (tag == element) {
                        word = "<span class='namePerson' style='color:red;' data-toggle='tooltip' data-placement='top' title='Name of a person'>" + word + "</span>";
                        result += word + " ";
                    }

                    else {
                        result += word + " ";
                    }
                }

            })
        })
        $("#editor").html(" ");
        $("#editor").html(result);
    }

The problem is that looping the selected checkbox array (checkedElements) here

else {
                        result += word + " ";
                    } 

adds the words (that are not found) every time again. like so : Darién make make make. Number of repetition in make depends on how many checkboxes are selected.

Do you have an idea how to solve that and make that better ?




Unable to style checkboxes HTML/CSS

I'm unable to do any styling whatsoever on some HTML checkboxes. Any css fails to change the appearance of the checkboxes:

HTML:

<input type="checkbox" id="checkbox-1-1" class="regular-checkbox" />
    <nput type="checkbox" id="checkbox-1-2" class="regular-checkbox" />
    <input type="checkbox" id="checkbox-1-3" class="regular-checkbox" />
    <input type="checkbox" id="checkbox-1-4" class="regular-checkbox" />

CSS:

.regular-checkbox {
  position: absolute;
  top: 0;
  left: 0;
  height: 25px;
  width: 25px;
  background-color: #eee;
}

Checkbox is unchanged. Can anyone tell me what I'm doing wrong here? I thought this was possible in CSS.




How use Regex from uncheck all files by file formats

i need uncheck many files from this HTML with JQuery HTML:

<div class="well">
  <h2>Select you files</h2>
  <table id="list-files" class="table table-bordered table-striped table-condensed table-hover">
    <tbody>
      <tr>
        <th width="10px"><input type="checkbox" id="select-all-files" checked="checked"></th>
        <th>File</th>
        <th>Size</th>
      </tr>
      <tr class="selectedFiles" style="display: table-row;">
        <td><input type="checkbox" name="files[]" value="0" checked=""></td>
        <td>
          <div><span class="pull-left">The.Blind.Side.2009.1080p.BluRay.x264.DTS-FGT/</span><span style="padding-top:1px;padding: 0 2px;display:block;overflow:hidden"><input style="width:100%;color:#c8c8c8;background-color:transparent;padding:0px;margin:0px" type="text" name="rename[0]" value="Visit thist Web.com.txt"></span></div>
        </td>
        <td>34.0 iB</td>
      </tr>
      <tr class="selectedFiles" style="display: table-row;">
        <td><input type="checkbox" name="files[]" value="1" checked=""></td>
        <td>
          <div><span class="pull-left">The.Blind.Side.2009.1080p.BluRay.x264.DTS-FGT/</span><span style="padding-top:1px;padding: 0 2px;display:block;overflow:hidden"><input style="width:100%;color:#c8c8c8;background-color:transparent;padding:0px;margin:0px" type="text" name="rename[1]" value="The.Blind.Side.2009.1080p.BluRay.x264.DTS-FGT.mkv"></span></div>
        </td>
        <td>8.8 GiB</td>
      </tr>
      <tr class="selectedFiles" style="display: table-row;">
        <td><input type="checkbox" name="files[]" value="2" checked=""></td>
        <td>
          <div><span class="pull-left">The.Blind.Side.2009.1080p.BluRay.x264.DTS-FGT/</span><span style="padding-top:1px;padding: 0 2px;display:block;overflow:hidden"><input style="width:100%;color:#c8c8c8;background-color:transparent;padding:0px;margin:0px" type="text" name="rename[2]" value="The.Blind.Side.2009.1080p.BluRay.x264.DTS-FGT.nfo"></span></div>
        </td>
        <td>5.4 KiB</td>
      </tr>
    </tbody>
  </table>
</div>

SCRIPT:

var inp=$("tr input");
var r="Visit thist Web.com.txt";
for (i = 0; i < inp.length; i++) {
 if(inp[i].value == r){
  inp[i-1].checked = false;
 }
}

How to improve this code?

This script uncheck only var r="Visit thist Web.com.txt"; and i need uncheck all files with .txt! it's true this example only has one .txt, but that usually changes, even the order. I would also like to unmark files with .nfo, .url, jpg, gif that's why I suppose it would be best to do it with regex

for tampermonkey on chrome

Thank




Checkbox data to firebase

How can I add checkbox values to my firebase database? Now I'm using edittext to store an item in the database. I want it to be checkable with a checkbox. And that it saves the checkboxes state even if I restart my app.

I've searched for an answer here, but no luck:( So I'm trying to ask for my self.

Model class:

public class Items {

String itemId;
String itemname;

public items(){


}

public Items (String itemId, String itemname){
    this.itemId = itemId;
    this.itemname = itemname;

}

public String getItemId() {
    return itemId;
}

public String getItemname() {
    return itemname;
}

Adapter:

public class listItems extends ArrayAdapter<Items> {

private Activity context;
private List<Items> listitems;



public listItems(Activity context, List<Items> listitems){
    super (context, R.layout.list_items, listitems);
    this.context = context;
    this.listitems = listitems;

}
@NonNull
@Override
public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = context.getLayoutInflater();


    View listViewItem = inflater.inflate(R.layout.list_items, null, true);

    TextView tvitemname = (TextView) listViewItem.findViewById(R.id.tvitemname);
    CheckBox checkBox = (CheckBox) listViewItem.findViewById(R.id.checkbx);



    Items items = listitems.get(position);

    tvitemname.setText(items.getItemname());






    return listViewItem;
}




How to pass value through unselected checkbox in django forms?

I Used to pass value through selected checkbox

 <input class="product-active-checkbox" type="checkbox" name="ingredient_id" checked=""
                                   value="" id="">

like wise, I want to pass "0" value through unselected checkbox? Or, Is there any way to identify unselected checkbox in django template?




WPF CheckBox is not checked when clicked between text and box

I have CheckBox with custom style, where the content(text) is shown with 12,0,0,0 margin. So there is the little space between box and text.

enter image description here

After clicking on a box or text checkBox get's selected, but when I click on margin space nothing happens.

Does anybody know what where the problem can be? I would very appreciate any answer.




how to use checkbox and input type number together in php

I am creating a meeting room booking application using php. In that, when a person book a room there have an option to book tea or snacks and specify the number of items they need. For that, I use checkboxes to select items and input type number to specify the number of items.i.e, if tea selected you have to specify the no. of tea in the input field. My problem is that I can't store or display the checkbox value and associated number together.my code is

<form class="form-horizontal" method="post" id="bookroom" action="bookedreview.php">
<h4>Food & Beverages</h4>
<div class="checkbox">
 <input type="checkbox" value="tea" name="food[]"><label>Tea</label>
 <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="coffee" name="food[]"><label>Coffee</label>
    <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="snacks" name="food[]"><label>Snacks</label>
    <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="water" name="food[]"><label>Water</label>
    <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="nuts" name="food[]"><label>Nuts</label>
    <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="breakfast" name="food[]"><label>Breakfast</label>
    <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="lunch" name="food[]"><label>Lunch</label>
    <input type="number" name="foodnum[]">
</div>
<div class="checkbox">
    <input type="checkbox" value="dinner" name="food[]"><label>Dinner</label>
    <input type="number" name="foodnum[]">
</div>
<input type="submit" name="submit" value="value">
</form>


if (isset($_POST['submit']))
{
  $foodnum=$_POST['foodnum'];
  $food=$_POST['food'];
  //$food=implode(',',$_POST['food']);
  foreach($foodnum as $index =>$value){
    $fud=$value;
    $num=$foodnum['index'];
 }
}

but when I display the variable I couldn't get the result. Can anyone help me how could store the checked items and the associated quantity together.




Feature to be installed depending upon user selection using checkbox in wix installer

I have created the dialog in wix which has 3 checkbox. user can select either one or all at a time. depending upon the selection of check box the feature needs to be selected and installed.

Suppose I have 3 application (ABC, DEF, GHI) and these are defined in the feature with condition statement.

<Control Id="ABC" Type="CheckBox" X="190" Y="110" Width="50" Height="17" Property="PQR" CheckBoxValue="1" Text="ABC">

similarly for other 2 application also I have the checkbox control.

Now I have 3 features like below.

<Feature Id="abc" Title="ABC" Level="0">
  <Condition Level="1"><![CDATA[PQR="1"]]></Condition>
  <ComponentRef Id="InstallABC"/>
</Feature>

I don't want to add the PQR as property in product.wxs because I don' want the checkbox to be selected by default.

Is it possible to do it using custom action.

Any answer or suggestions will be grateful.




how to send checkbox data in reactjs

I do not how to explain properly, but I will try. I have a multiple checkboxes that represents which day of week the shop will be opened. So, I have this data api

enter image description here

, where day_of_week tells in which day the checkbox should be checked. Ex. see here

enter image description here

I need to send the right attribute to the server, which is day_of_week to change the status of checkbox. However, now only one of the checkboxes can be checked. This is my code

  {businessGroup.opening_hours ? businessGroup.opening_hours.map((open_hour, i) => (
              <div key={i} className="openHours d-flex">

                <DatePicker
                  placeholder="Start Date"
                />
                <DatePicker
                  placeholder="End Date"
                />

                <div className="weekDays">
                  {
                    ['Mo1', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'].map((day, inx) => (
                      <div className="weekChekbox" key={inx}>
                        <div>{day}</div>
                        <Checkbox
                          checked={open_hour.day_of_week === inx}
                          onChange={() => this.setState({
                            businessGroup: {
                              ...businessGroup,
                              opening_hours: [
                                ...businessGroup.opening_hours.splice(0, i),
                                {
                                  ...businessGroup.opening_hours[0],
                                day_of_week: inx,
                                },
                                ...businessGroup.opening_hours.splice(1),
                              ],
                            },
                          })}
                        />
                      </div>
                    ))

                  }
                </div>
})

Do not pay much attention to closing bracket it is not important now, cause I just cut the piece of code from whole code. So, how i should make my onChange correctly to send the day_of_week correctly and any checkboxes can be checked.

Thank you)




lundi 26 novembre 2018

Datatable checkbox issues

View:

<?php 
    $attributes = array('class' => 'form-horizontal', 'id' => 'Form');
    echo form_open($loginRedirect2,$attributes);
?>

<div class="stock_report" id="table_stock"> 

    <div class="stock_report" id="table_stock_print"> 
        <table id="order-listing" class="table">
            <thead>
                <tr class="bg-light">
                    <th><input type="checkbox" name="selectAll" id="selectAll" class="form-control" data-to-table="tasks" value=1></th>
                    <th>Code</th>
                    <
                </tr>
            </thead>
            <tbody class="reportData">
                <?php
                    if(is_array($employees)){
                    foreach($employees as $employee){
                ?>

                <tr>
                    <td class="a-center "><input type="checkbox" name="selectall[]" class="form-control" value="<?php echo $employee['employeeId']; ?>"/></td>
                    <td><?php echo $employee['Code'];?></td> 

                </tr>
                <?php
                    }
                    }else{
                ?>
                <?php
                    }   
                ?>
            </tbody>
            <tfoot>
                <tr class="bg-light">
                    <th><input type="checkbox" name="selectAll" id="selectAll" class="form-control" data-to-table="tasks" value=1></th>
                    <th>Code</th>

                </tr>
            </tfoot>
        </table>
    </div>
</div>
<div class="shift_category form-group">

    <button type="submit" class="btn btn-primary">Submit</button>
</div>
<?php echo form_close();?>

Script:

$(document).ready(function() {
        var oTable = $('#order-listing').dataTable( {
            initComplete: function () {
                this.api().columns().every( function () {
                    var column = this;
                    var select = $('<select><option value=""></option></select>')
                        .appendTo( $(column.footer()).empty() )
                        .on( 'change', function () {
                            var val = $.fn.dataTable.util.escapeRegex(
                                $(this).val()
                            );

                            column
                                .search( val ? '^'+val+'$' : '', true, false )
                                .draw();
                        } );

                    column.data().unique().sort().each( function ( d, j ) {
                        select.append( '<option value="'+d+'">'+d+'</option>' )
                    } );
                } );
            },
            columnDefs: [ {
                orderable: false,
                className: 'select-checkbox',
                targets:   0
            } ],
            select: {
                style:    'multi',
                selector: 'td:first-child'
            },
            lengthMenu: [[20,50, 100, -1], [20, 50, 100, "All"]],
            pageLength: 20 
         } );
        var allPages = oTable.fnGetNodes();

        $('body').on('click', '#selectAll', function () {
            if ($(this).hasClass('allChecked')) {
                $('input[type="checkbox"]', allPages).prop('checked', false);
            } else {
                $('input[type="checkbox"]', allPages).prop('checked', true);
            }
            $(this).toggleClass('allChecked');
        });




    } );

Here is my datatable view and script.I added a checkbox to this datatable.But the problem is selectall option of checkbox is not properly working.Here this is a modal view.First time when i click the selectall button it is not working.When I press the escape button ,then open the modal,the selectall checkbox box click is working.How to solve this issue.




Unchecking a checkbox

(AWT) I have a frame with a text field + a checkbox group consisting of 8 checkboxes. I want to check a box, enter the text info, and perform an action. Then the 2nd time in I would like the text to remain as is and all of the boxes to be UN-checked. To that end, after the 1st action, I uncheck the box with "this:dispCB.setState(false)"; Unfortunately is doesn't uncheck anything, but if I simply check any other box, then it clears the last used box and I can go back and use it again. Not a good solution. Any suggestions? Thanks!




Vue - V-Bind Disabled Attribute On Webforms Checkbox Control

I have the following code:

JS Vue

new Vue({
    el: '.XXX',
    data: {},
    computed: {
        disableCbInScreens: function () {               
            return true;
        }
    }
});

Webforms

<asp:CheckBox ID="test" runat="server" v-bind:disabled="disableCbInScreens" />
<input ID="test2" v-bind:disabled="disableCbInScreens" type="checkbox" />

Server-Side C#

test.Attributes["v-bind:disabled"] = "disableCbInScreens";

This first checkbox is disabled, the second is not, it's like Webforms is stripping the "V-Bind" from the rendered "input" control. I would like the be able to use Vue's V-Bind for the "asp:CheckBox" control, how can I do this?




Excel - Checkboxes, Sheet1 to select which rows you don't want, Sheet2 with unwanted rows hidden

First of all, I'm using Excel 2013.

Basically I want checkboxes to control which row is/isn't printed on my document.For exemple, I have 2 worksheets : EnterSheet and PrintSheet. PrintSheet is copied directly from EnterSheet. On EnterSheet, each rows have a checkbox that I would deactivate to hide the corresponding row in PrintSheet. The user can simply check which rows he wants in EnterSheet and print out PrintSheet that contains only what he needs.

I've uploaded a screenshot to showcase what I actually want from my Excel file : https://imgur.com/a/otorlaX EnterSheet is where the user select which rows he needs, then he just has to print PrintSheet to complete his work.

I know how to make the Checkboxes, and I have very basic knowledge on VBA and macros so I can surely set something up with some help. Something that I've thought I could maybe do is to add a column which contains the boolean value of the checkboxes, and have them associated with a macro that checks if it's true/false and unhide/hide the corresponding row on the PrintSheet, but I have no clue how to set that up and I have issues with relative references concerning different sheets. Would it be possible, as an exemple, to store the Checkbox's position in a variable and use this variable to select the same row in PrintSheet?

I'll add that I've tried using the Group (outline) feature. Unfortunately it almost matches my needs but not quite because you cannot group, let's say, row 3-4 and 5-6 separately, it will make a single group of 4 rows instead of 2 groups of 2 rows.

Thanks in advance!




checkbox checked after reloading pages and backing to previous page

I need only which I checked! not all.

<?php if (isset($_SESSION["design"])) { ?>
<input type="checkbox" onkeypress="isInputNumber(event)" name="design" value="<?php echo $design_id; ?>" checked>
<?php } else {?>
<input type="checkbox" onkeypress="isInputNumber(event)" name="design" value="<?php echo $design_id; ?>">
<?php } ?>




CSS: Is there a way to detect using only CSS when all checkboxes in a form are checked?

I understand that I can use the following to style checkboxes that are checked:

.form-check-input:checked + label {
  color: blue
}

I have a form with a varying number of multiple checkboxes. Is there a way to apply the style only if all checkboxes in a form are checked?

I would like to do this in CSS only.




Android check box button style for API < 21

I added a style for a checkbox like below

<style name="SurveyCheckBox" >
    <item name="colorControlNormal">@color/colorPrimaryLight</item>
    <item name="colorControlActivated">@color/colorSecondary</item>
    <item name="colorControlHighlight">@color/colorSecondaryDark</item>
</style>

It works perfectly but I also added this style for checkboxes created dynamically in a recycler view. In this case, style does not affect checkboxes. To solve this problem, I added "android:" before the item name.

<style name="SurveyCheckBox" >
    <item name="android:colorControlNormal">@color/colorPrimaryLight</item>
    <item name="android:colorControlActivated">@color/colorSecondary</item>
    <item name="android:colorControlHighlight">@color/colorSecondaryDark</item>
</style>

This property works in API >=21 but does not work <21. Is there any solution for this problem?

recycler_view_layout.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:padding="10dp">

<TextView
    android:id="@+id/survey_check_text"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_gravity="left|center"
    android:layout_weight="8"
    android:textColor="@color/colorOnBackground"
    android:textSize="16sp" />

<CheckBox
    android:id="@+id/survey_check_box"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:theme="@style/SurveyCheckBox" /> </LinearLayout>




Write jquery scripts dinamic

I need to write scripts in jQuery for checkbox's event's dinamically, this is my html code:

<fieldset>
            <label>
                <input type="checkbox" name="radio0" id="radio0">
                <img id="img0" src="web_bg.jpg" width="200" height="200"/>
            </label>
            <label>
                <input type="checkbox" name="radio1" id="radio1">
                <img id="img1" src="web_bg.jpg" width="200" height="200"/>
            </label>
            <label>
                <input type="checkbox" name="radio2" id="radio2">
                <img id="img2" src="web_bg.jpg" width="200" height="200"/>
            </label>
            <label id="label">3</label>
</fieldset>

and this is my jQuery script that works :

$('#radio0').click(function () {
                if ($(this).is(':checked')) {
                    $('#img0').css("opacity", "0.5");
                } else {
                    $('#img0').css("opacity", "1");
                }
            });
            $('#radio1').click(function () {
                if ($(this).is(':checked')) {
                    $('#img1').css("opacity", "0.5");
                } else {
                    $('#img1').css("opacity", "1");
                }
            });
            $('#radio2').click(function () {
                if ($(this).is(':checked')) {
                    $('#img2').css("opacity", "0.5");
                } else {
                    $('#img2').css("opacity", "1");
                }
            });

but i want to put this code in a bucle like this (but this don't works):

var text = $('#label').text();
            var max = parseInt(text);
            for (var i = 0; i < 3; i++) {
                $('#radio' + i + '').click(function () {
                    if ($(this).is(':checked')) {
                        $('#img' + i + '').css("opacity", "0.5");
                    } else {
                        $('#img' + i + '').css("opacity", "1");
                    }
                });




if checkbox is unchecked during form submission then it will become red

I have a register form and there I have two checkboxes. If it is unchecked and the client clicks on register button then it will become red.

Following is my checkbox codes:-

$('#age_confirmation').change(function(){
    var c = this.checked ? '' : 'red';
    $('#age_confirmation').css('color', c);
});
$('#terms_of_service').change(function(){
    var c = this.checked ? '' : 'red';
    $('#terms_of_service').css('color', c);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="" method="post" accept-charset="utf-8" class="form-signin form-register" role="form" id="register" autocomplete="off">
  <div style="display:none"></div>
  <input type="checkbox" id="age_confirmation" name="age_confirmation" required tabindex="10"/> Age Confirmation
  <input type="checkbox" id="terms_of_service" name="terms_of_service" required tabindex="11"/> Terms of Service
  <input type="submit" class="btn btn-tiffany" value="register" />
</form>

Can anyone tell me where I'm wrong. Any help will be appreciated.




Add and remove values inside array in change event of checkbox

In my angular application, i am making a checkbox and capturing the checkbox change event and pushing the checked value into array..

Here if we uncheck the checkbox also the obj were pushed to the array..

How to remove the obj from array if uncheck the checkbox..

Html:

<div *ngFor="let item of order; let i = index">
  <input type="checkbox" [id]="item+i" [name]="item"[(ngModel)]="item.Checked" (change)="getCheckboxValues(item)">
   <label [for]="item+i">  </label>
</div>

Ts:

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

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  name = 'Angular';

  order = ['One','Two','Three','Four'];

  newArray : any = [];

  //Checkbox Change detecting function
  getCheckboxValues(data) {
    let obj = {
      "order" : data
    }

   // Pushing the object into array
    this.newArray.push(obj);

    //Duplicates the obj if we uncheck it
    //How to remove the value from array if we uncheck it
    console.log(this.newArray);
  }

}

The thing i have worked out with the above was in the link https://stackblitz.com/edit/angular-9pt9sn

Kindly help me to remove the unchecked values inside the ``newArray```..




dimanche 25 novembre 2018

checked = "checked " stops working when I add ngModel in mat-checkbox

My mat-checkbox's checked = "checked" stops working when I add an ngModel to it.

This will work.

<mat-checkbox name="BlackBeard" ngModel checked = "checked"> Zehahaha? </mat-checkbox>

This will not work.

<mat-checkbox name="BlackBeard" ngModel checked = "checked"> Zehahaha? </mat-checkbox>




Getting error while submitting the multiple checkbox value using codeigniter

I am getting some error while submit the form having multiple checkbox value using code-igniter. I am explaining my code below.

filter.php:

<form class="listing_filter"  action="<?php echo $baseUrl;?>search" method="GET" style="background:#f2f2f2;">
foreach($moduleTypes as $mtype){
   if(!empty($mtype->name)){
      <div class="go-right">
         <div class="checkboxTypeRadioUI">
         <input type="checkbox" value="<?php echo $mtype->id;?>" name="type[]" id="<?php echo $mtype->name;?>" class="checkbox filled-in go-right" <?php if($mtype->id == $vartype){echo "checked";}?> /><label for="<?php echo $mtype->name;?>" class="css-label go-left"> &nbsp;&nbsp; <?php echo $mtype->name;?> &nbsp;&nbsp;</label>
     </div>
       </div>
     <div class="clearfix"></div>
   }
}
<button style="border-radius:0px;margin-bottom:0px;" type="submit" class="btn btn-action btn-lg btn-block loader" id="searchform">Search</button>

</form>

My controller side code is given below.

Tour.php:

function search($country = null, $city = null, $citycode = null,$offset = null) {
  $type = $this->input->get('type');
  print_r( $type);exit;
}

Here when I am clicking on search button 500 Internal Server Error is coming . Here I need to get the multiple checkbox values.




Total sum of checkbox values

I have a simple checkbox code, 2 checkboxes per group.

    <div class='product-addon'>
        <p>Interfejsy</p>
        <label>
            <input id='option0' type='checkbox' name='Interfejsy' value='150.00'>
            Moduł rozszerzenia 1: 2x RS232 <span class='addon-price'>150,00</span>
        </label>
        <label>
            <input id='option1' type='checkbox' name='Interfejsy' value='370.67'>
            Moduł rozszerzenia 2: WiFi <span class='addon-price'>370,67</span>
        </label>
    </div>
    <div class='product-addon'>
        <p>BAZA</p>
        <label>
            <input id='option0' type='checkbox' name='BAZA' value='60.00'>
            Rozszerzenie bazy PLU o 2000 kodów  <span class='addon-price'>60,00</span>
        </label>
        <label>
            <input id='option1' type='checkbox' name='BAZA' value='80.00'>
            Rozszerzenie bazy PLU o 4000 kodów  <span class='addon-price'>80,00</span>
        </label>
    </div>

My question is: How i can get total sum of price (checkbox.val()) when user click checkbox? For example user click checkbox in first group with value=150.00, and click checkbox in second group with value=80.00? Total sum should be 230.00 Important: user can select only one checkbox in group.

I have that js code:

    var totalSum = 0;
    $("input:checkbox").on('click', function() {
      var $box = $(this);

      if ($box.is(":checked")) {
        var group = "input:checkbox[name='" + $box.attr("name") + "']";
        var addonPrice = parseFloat($box.val());
        $(group).prop("checked", false);
        $box.prop("checked", true);
      } else {
        $box.prop("checked", false);
      }

      totalSum += addonPrice;
      console.log(totalSum);
    });

but the variable totalSum is always getting higher, when i click any addon. For example i click checkbox in group 1 with value=150, next click checkbox in group 2 with value=60, totalSum = 210 it's good, but when i click again some checkbox it's adding next value.

I just wan't something like this: 1) User click checkbox in group 1 with value=150 2) User click checkbox in group 2 with value=60 3) totalSum is 210 4) User click checkbox in group 2 with value=80 5) totalSum is 230, not 290

Thanks for any suggestions




Element not visible for check box though its available

I am trying to tick a checkbox using Selenium. The page looks like below.

enter image description here

Then when I click on edit, it changes to the below shown format.

enter image description here

At this time, I can select the checkbox from Chrome dev tools using the below shown xpath.

//input[@name='value[326071]']

Below is how the DOM looks.

enter image description here

I have put a thread wait before clicking on the check box. Below is my code.

Thread.sleep(5000);
WebElement assignWorkSpaceElement = chromeDriver.findElement(By.xpath("//input[@name='value[326071]']"));
assignWorkSpaceElement.click();

I tried with the below xpath as well. Still no luck. I am debugging the code through IntelliJ and prior to going over the web element line, I am able to select the checkbox from Chrome dev tools. Its clearly there.

//*[contains(@class,'col-md-8')]//input[@name='value[326074]']

but when I execute the code, I get the following exception.

org.openqa.selenium.ElementNotVisibleException: element not visible
  (Session info: chrome=70.0.3538.110)
  (Driver info: chromedriver=2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363),platform=Mac OS X 10.13.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

What am I doing wrong here? Any help would be much appreciated.




Get checkbox values from JSP Page

I'm trying to get all the values from a list of checkboxs in a JSP Page, to a Java Class. That's My JSP Page:

    <table border="1" cellpadding="5" cellspacing="1" style="width: 877px; ">
   <tr>
      <th>Code</th>
      <th>Name</th>
      <th>Price</th>
      <th>Select</th>
      <th>Edit</th>
      <th>Delete</th>
      <th>Show</th>
   </tr>
   <c:forEach items="${productList}" var="product" >
      <tr>
         <td>${product.code}</td>
         <td>${product.name}</td>
         <td>${product.price}</td>
         <td>
         <input type="checkbox" name="ProductItem"  value="${product.code}">
             <c:url value="ShowProductList" var="url">
             <c:param name="ProductItemP" value="${product.code}"/>
             </c:url> 
         </td>
         <td>
            <a href="editProduct?code=${product.code}">Edit</a>
         </td>
         <td>
            <a href="deleteProduct?code=${product.code}">Delete</a>
         </td>
         <td>
            <a href="ShowProduct?code=${product.code}">Show</a>
         </td>
      </tr>
   </c:forEach>
</table>


 <a href="${url}">Show Items</a>

As you can see there is a Table with a list of items with a check box in each line. At the end of the table there is button "Show Items" that triggers the user's request. That's the servlet class that perform the request:

    @WebServlet(urlPatterns = { "/ShowProductList" })
public class ShowProductList extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public ShowProductList() {
        super();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        Connection conn = MyUtils.getStoredConnection(request);

             String[] paramValues = request.getParameterValues("ProductItemP");
             System.out.println(paramValues.length);
             response.sendRedirect(request.getContextPath() + "/productList");      
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request, response);
    }

}

When an user click on the button I can have only the last product code with the checkbox clicked. If I Try `request.getParameterValues("ProductItem"); I have a null value. I'd prefer to not hove code in the JSP Page (if it is possible.) Can someone help me find a solution ? Thanks for your patience.

`




Get loop data of angular 6 html table on seprate button click

I am working on new angular 6 application and i am new to angular 6.

I have to implement the new function like.i am having one html table with multiple column some of them have checkbox along with id in hiddenfield. Now i have one button which is outside html table.

Now on the hutton click i have to get selected rows of one checkbox column. I have tried to search same on google but not getting any good solution for this.

Can anyone help to achive these functionality.

Thanks in advance. Omkar




samedi 24 novembre 2018

Very very Simple AngularJS Dropdown displaying a list of values with multiselect checkboxes

Very very Simple AngularJS Dropdown displaying a list of values with multiselect checkboxes

I would like to make a dropdown with a list of values, where one can multiselect among these values with a checkbox on each value in the dropdown list. I want to be able to react to the event when one checks or unchecks the checkbox for one of the values I display in dropdown.

I would like the solution to be as simple as possible, so if it can be made without some custom directive, or third party library. I would prefer that.

So basically I just want to display a totally plain AngularJS drop down, with a check box for each value in the dropdown list. Something like just adding a checkbox to it and make it able to perform multiselect. The dropdown should also be scrollable. https://docs.angularjs.org/api/ng/directive/select

I have found some more complex solutions to give you an idea about what I want: enter code herehttps://codepen.io/elmahdim/pen/hlmri enter code herehttps://jsfiddle.net/michaeldeongreen/22et6sao/9/ But I find these solutions too complex and would like something really simple if possible.




List Items individually with labels

Good Afternoon,

Im looking to create a small currently selected options element for a website, im fairly new when it comes to anything JS related. How could I adjust the code below to list the selected items individually between their own tags?

function checkCount(elm) {
      var checkboxes = document.getElementsByClassName("checkbox-btn");
      var selected = [];
      for (var i = 0; i < checkboxes.length; ++i) {
        if(checkboxes[i].checked){
            selected.push(checkboxes[i].value);
        }
        }
      document.getElementById("proId").value = selected.join();
      document.getElementById("total").innerHTML = selected.length;
    }
<label class='checkbox-inline'><input type='checkbox' class='checkbox-btn' value='1' onchange='checkCount();'></label>
    <label class='checkbox-inline'><input type='checkbox' class='checkbox-btn' value='2' onchange='checkCount();'></label>
    <label class='checkbox-inline'><input type='checkbox' class='checkbox-btn' value='3' onchange='checkCount();'></label>

    <input type="text" name="proId" id="proId">

<div>Total Selected : <span id="total">0</span></div>



vendredi 23 novembre 2018

C# checkbox direct download file

I have trouble assinging a download to checkbox , for starters in the event of checking to download a specific file in the current folder. I plan to add cancel+delete on unchecked later... if I get this working The problem is that it creates an empty file , but the download never occurs. I really want it to download on check, without using a separate button that triggers the event.

public void downloadFile(String address, String filename)
    {
        WebClient down = new WebClient();
        down.DownloadFileAsync(new Uri(address), filename);
    }
    private void Autor_Checked(object sender, RoutedEventArgs e)
    {
        downloadFile("https://live.sysinternals.com/autoruns.exe", "autoruns.exe");
    }




Bootstrap 4 - Checkbox not Working Properly inside Popover in Bootstrap Modal

There are two checkboxes inside popover in Bootstrap Modal. The fiddle is here.

HTML:

<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <button type="button" class="btn btn-primary open-modal" data-toggle="modal" data-target="#bs-modal">
            Open Modal
            </button>
            <div class="modal fade" id="bs-modal" tabindex="-1" role="dialog" aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel">Bootstrap 4 Modal</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <button type="button" class="btn btn-secondary btn-sm bs-popover" data-container="body" data-toggle="popover">
                            Show Popover
                            </button>
                            <div id="popover-content">
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" value="1"
                                        id="default-checkbox" name="default-checkbox">
                                    <label class="form-check-label" for="default-checkbox">
                                    Default Checkbox
                                    </label>
                                </div>
                                <br>
                                <div class="custom-control custom-checkbox">
                                    <input type="checkbox" class="custom-control-input" id="custom-checkbox" name="custom-checkbox" value="2">
                                    <label class="custom-control-label" for="custom-checkbox">Custom Checkbox</label>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                            <button type="button" class="btn btn-primary">Save changes</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

CSS:

.open-modal {
    margin: 20px;
}
.modal-body {
    min-height: 200px;
}
#popover-content {
    display: none;
}

JS:

$('.bs-popover').popover({
    html: true,
    content: function() {
        return $('#popover-content').html();
    },
    title: 'Popover Title'
});

1. Problem with Default Checkbox: I'm not able to check it by clicking the label.

2. Problem with Custom Checkbox: It cannot be checked.

Why is this happening? How can I fix it? Any help would be appreciated.




Coding a Button to display a list of items in a ListBox

I'm having tremendous trouble in coding a Button that will display items, that I have selected in a program, in a ListBox.

Public Class Form1
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        If rdoNormal.Checked = True Then
            txtTotal.Text = 1.05
        ElseIf rdoThicc.Checked = True Then
            txtTotal.Text = 1.05
        ElseIf rdoCrusty.Checked = True Then
            txtTotal.Text = 1.05
        ElseIf rdoCob.Checked = True Then
            txtTotal.Text = 1.05
        End If

        If rdoSausage.Checked = True Then
            txtTotal.Text = Val(txtTotal.Text) + 1.8
        ElseIf rdoTurkey.Checked = True Then
            txtTotal.Text = Val(txtTotal.Text) + 3.25
        ElseIf rdoCheese.Checked = True Then
            txtTotal.Text = Val(txtTotal.Text) + 2.4
        ElseIf rdoPopchick.Checked = True Then
            txtTotal.Text = Val(txtTotal.Text) + 0.84
        End If

        If chkMayo.Checked = True Then
            txtTotal.Text = Val(txtTotal.Text) + 0.6
        End If

        If chkButter.Checked = True Then
            txtTotal.Text = Val(txtTotal.Text) + 0.6
        End If
    End Sub

    Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
        lstReceipt.Items.Clear()
    End Sub

    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Application.Exit()
    End Sub

    Private Sub btnReceipt_Click(sender As Object, e As EventArgs) Handles btnReceipt.Click
       **(What do I put here?)**
    End Sub
End Class




Dynamic limit of Checkbox Group selection

I have a checkboxGroupInput with 4 choices (A, B, C, D).
I want to limit the allowed selection to 2 options.

The user is allowed to select a 3rd option.
But in that case only the new (3rd) and last (2nd) options that were selected should stay checked.

For example, if a user selects B, then D, and then A -
the outcome should be only D and A checked.

I'm trying to implement this logic in JS, since it doesn't work properly in R/Shiny.
The main reason is that updating the input doesn't occur immediately.
(it is delayed by other invalidations in my original Shiny app, that take quite some time)

Minimal example:

library(shiny)

shinyApp(
  ui = fluidPage(
    tags$script(
      "JS code here..."
    ),

    checkboxGroupInput(
      inputId = "the_checkbox",
      label = "Checkbox",
      choices = c("A", "B", "C", "D")
    )
  ),

  server = function(input, output, session) {}
)




How can I click a checkbox and know if checked or not checked?

$('.p_check').click(function() {
          if ($(this).is(':checked')) {
              alert("checked");
          } else {
               alert("unchecked");
          }
       });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class='checkbox p_check'><label><input type='checkbox'>New Password</label></div>

My alert is always "unchecked", no matter if I check or uncheck it




jeudi 22 novembre 2018

inserting and selecting multiple values of checkbox in mssql stored procedure

here is where I get the values of the checkboxes. It is working. `

                    echo "<div class='table-responsive' >";
                          echo "<table class='table table bordered' style='font-size: 14px'>";
                          echo "<th style = ''> Action</th>"; 
                          echo "<th style = ''>Document</th>"; 
                    echo "</div>";

                        $cntr = 1;

                while ($row = sqlsrv_fetch_array($loadDocs)) 
                        {
                        echo "<tr>"; 

                        echo "<td  style = 'text-align:center;width:10%'>
                        <input type='checkbox' id='NAMING".$cntr."' value='".$row['DocCode']."' /></td>";
                        echo"<td  style = 'width:10%''>".$row["DocDesc"]."</td>";

                        echo "</tr>"; 
                        $cntr++;
                      }
                      ?>`

Help this is my php code for the selection and insertion of checkbox values in mssql stored procedure. I cant figure out what is wrong with the code. Please help.

`<?php

 if(isset($_POST['BTN_Proceed']))
 {
      $x=1;
      $BankName = $_POST['BankName'];
      $BankCode = $_POST['BankCode'];
      $DocCode  = $_POST['DocCode'];
      $rowCount = $_SESSION["rowCount"];

      while ($x < $rowCount)
          {
                    $insertDocsParam = array(array($BankName,SQLSRV_PARAM_IN),
                                                array($BankCode,SQLSRV_PARAM_IN),
                                                array($Doccode,SQLSRV_PARAM_IN),
                                                array($_POST["NAMING".$x],SQLSRV_PARAM_IN),);

                    $insertDocs = sqlsrv_query($conn, '{CALL sp_SRP_Insert_Doc (?,?,?,?)}', $insertDocsParam) or 
                    die( print_r( sqlsrv_errors(), true));;
                    $x++;
          }
      }   
?>`




How to retrieve checkbox value from table structured data?

I have a table which is having checkbox for each column as shown below:

enter image description here

When I click on the submit I need checked value for each row and particular column. How I can achive that?Please help me in this regard.




mercredi 21 novembre 2018

Tkinter checkbox remember the state after I close the window that contains it

I'm making a Python project. I need to add a chexk box to every window I create, it works fine... but when I close it and open it again the checkbox is always unchecked. Is there anyway to make the checkboxes remember the states they had before they were closed? Ps: for this project, the quantity of windows depend on the user.




Save checked Chechbox into sqlite database with javascript

I have a form in my ejs with several checkboxes. In the application the user should be able to choose his interests by checking the checkboxes and this should be saved into a sqlite Database table. I'm building the table via bootstrap:

db.exec('CREATE TABLE interests(interest text)');

(not sure which type to choose, so I set it to "text", but this is probably wrong?). My Form looks like this

<form name="first_steps" action="first_steps" method="post">
  <ul>
    <li>
        <input type="checkbox" name="interesse" value="theater" id="check1">Theater</label>
    </li>
    <li>
        <input type="checkbox" name="interesse" value="musik" id="check2">Musik</label>
    </li>
    <li>
        <input type="checkbox" name="interesse" value="party" id="check3">Party</label>
    </li>
    <li>
        <input type="checkbox" name="interesse" value="sport" id="check4">Sport</label>
    </li>
</ul>
<input type="submit" value="submit">

I found this Article Save result checkboxes checked in form into sqlite database with javascript and tried to convert this into my server.js

(Something like this

app.post('/first_steps', function(req, res) {
var elementen = document.getElementsByName ("interesse");
var tmpChoise;
for (var r= 0; r < elementen.length; r++) {
    if (elementen[r].checked) {
    tmpChoise = elementen[r].value;
    alert(tmpChoise);
    db.run(`INSERT INTO interessen(interesse) VALUES (?)`, [interesse], function(err) {
            return res.redirect('/profil');
        });
  }
 } 
});

but this doesn't work. It says "ReferenceError: document is not defined").

Can someone tell me how the right code would look like? I'm a bloody beginner and couldn't really figure anything out.

(Javascript, express, sqlite3, node.js)




How to change img with JavaScript using radio button and switch case?

I want to have a background image depending on the checked radio button, using a switch case. However I'm not finding the right solution to get the value from the checked radio button.

Snippet of my code:

HTML:

<section class="configurator__product">
       ...
</section>

<label for="blue" class="hidden">Blue</label>
<input type="radio" id="blue" name="color-totebag" value="tote-blue" class="circle tote-blue">
<label for="green" class="hidden">Green</label>
<input type="radio" id="green" name="color-totebag" value="tote-green" class="circle tote-green">
<label for="black" class="hidden">Black</label>
<input type="radio" id="black" name="color-totebag" value="tote-black" class="circle tote-black">

There's more inputs, 5 in total, hence the reason I don't think using if/else is optional. But I hope it gets clear with the amount of code I'm giving here.

JavaScript:

const changeTotebagColor = () => {
    let totebagColor = document.getElementsByName(`color-totebag`).value;
    const $totebagImg = document.querySelector(`.configurator__product`);

    switch (totebagColor) {
        case `tote-blue`:
            $totebagImg.style.backgroundImage = "url('assets/img/totebag_blue')";
        case `tote-green`:
            $totebagImg.style.backgroundImage = "url('assets/img/totebag_green')";
        case `tote-black`:
            $totebagImg.style.backgroundImage = "url('assets/img/totebag_black')";
    }
}

changeTotebagColor();

I hope it's a bit clear to what I'm trying to figure it out. I'm new to JavaScript, so maybe I'm doing this all wrong. I've tried numerous solutions online, however I had no luck. I would also like to avoid in-line JavaScript if possible, but I'm open to any solution at this point.




How to createe checkbox input for navigation menu added to categories left hand side

My Current navigation menu is without check box function. See below image.

image without check box feature

I want to create checkbox function for navigation menu. same as below image.

Navigation with check box

How can I do this?




Multiple Progress Bars Dynamically Change with Checkboxes with Multiple Values

A bit stumped... I have 3 checkboxes and 3 Bootstrap 4 progress bars. The progress bars represent different metrics, ie. progressOne = Power, progressTwo = Speed, progressThree = Size. When each of the checkboxes are selected, they increase each of these metrics from 20 by varying values and are individual or accumulative (ie, checkboxOne is selected, it will add '5' onto the 'Power' value, if I select checkboxThree as well, it will add an additional '40'.

So far I have multiple values being generated in the checkbox value with spaces separating ie

<input type="checkbox" id="checkboxOne" value="5 15 35" />
<input type="checkbox" id="checkboxTwo" value="0 25 0" />
<input type="checkbox" id="checkboxThree" value="40 0 20" />

I also have it so that, when these checkboxes are checked, it will dynamically change the first progress bar. The HTML for each bar is as follows with the ID changing.

<div class="progress">
  <div id="progressOne" class="progress-bar" role="progressbar" aria-valuenow="20" aria-valuemin="0" aria-valuemax="100">
</div>

The problem I have is from a technical understanding that I cannot target the 2nd or 3rd values being held in the checkbox value. What I am trying to do is split the 'item.value' so I can target value [2] or [3].

   //Bar 1
    var total = 0;
    function comProd(item){
        if(item.checked){
           total+= parseInt(item.value);
        }else{
           total-= parseInt(item.value);
        }
        var progSuccess = document.getElementById('progressOne');
        var totalVal = total + " ";
            progSuccess.setAttribute('aria-valuenow', totalVal);
            progSuccess.style.width = (total + 20) + "%";
    }   

When I try the following, it only targets a single integer

  //Bar 1
    var total = 0;
    function comProd(item){
        if(item.checked){
           total+= parseInt(item.value);
        }else{
           total-= parseInt(item.value);
        }
        var progSuccess = document.getElementById('progressOne');
        var totalVal = total + " ";
            progSuccess.setAttribute('aria-valuenow', totalVal);
            progSuccess.style.width = (total + 20) + "%";
    }   
    //Bar 2
    var totaltwo = 0;
    function comProdtwo(item){
        if(item.checked){
           totaltwo+= parseInt(item.value);
        }else{
           totaltwo-= parseInt(item.value);
        }
        var progSuccessTwo = document.getElementById('progressTwo');
        var totalValTwo = totaltwo + " ";
            progSuccessTwo.setAttribute('aria-valuenow', totalValTwo);
            progSuccessTwo.style.width = (totaltwo + 20) + "%";
    }       
    //Bar 3
    var totalthree = 0;
    function comProdthree(item){
        if(item.checked){
           totalthree+= parseInt(item.value);
        }else{
           totalthree-= parseInt(item.value);
        }
        var progSuccessThree = document.getElementById('progressThree');
        var totalValThree = totalthree + " ";
            progSuccessThree.setAttribute('aria-valuenow', totalValThree);
            progSuccessThree.style.width = (totalthree + 20) + "%";
    }       

I'm amazed I can't find a solution to this online but appreciate any direction.




Input text change checkbox model only once [AngularJS]

I have this

<input type="text" ng-click"function1()">

And this:

<input type="checkbox" ng-change="function2()" ng-model="stateCheck">

The functions do this:

$scope.function1 = function(){
  $scope.stateCheck = false;
}

$scope.function2 = function(){
  $scope.stateCheck = !$scope.stateCheck;
}

But the function1 just works the first time. Does anyone know why? Thanks.




mardi 20 novembre 2018

checkbox checked change will disabled the other checkbox

I have two checkboxes. If the first checkbox checked, the second checbox will be disabled and if the first checkbox unchecked, the second checkbox will be enabled.

<div class="data">
<asp:CheckBox ID="firstCheckBox" runat="server" CssClass="LabelText" EnableViewState="False" AutoPostBack="True" />
</div>

<div class="data">
<asp:CheckBox ID="secondCheckBox" runat="server" CssClass="LabelText" EnableViewState="False" AutoPostBack="True" />
</div>

Here is my control part at the Page_Load;

            if (firstCheckBox.Checked)
            {
                secondCheckBox.Enabled = false;

            }
            else
            {
                secondCheckBox.Enabled = true;
            }

When I checked the firstcheckbox, nothing happens to the secondcheckbox. After I checked the second checkbox, secondcheckbox has been checked and disabled.

What am I missing?




How to concatenate/remove string if a checkbox is checked or unchecked in Jquery?

Currently I am working on Skelta BPM software which uses Jquery as scripting language.

The trouble I am facing is that I want all the JobID value to be displayed in the textbox whenever they are checked and to remove the specific JobID value which is unchecked.I dont know how to achieve this.

var JobID = "";

//control.findByXmlNode("isSelected").value="1";

if (currentRowValue === undefined )
{
        control.findById("T1").value = "";
}


if (currentRowValue !== undefined )
{
  //control.findById("T1").value+=currentRowValue.JobID+",";
  
   if(control.findById("T1").value !== currentRowValue.JobID+",")
    {
        control.findById("T1").value+=currentRowValue.JobID+",";  
    }  
    
}
else
{
 control.findById("T1").value ="";

  var grid = $("[controlid = G1");
  var allRows = grid.find("tbody")[0].children;
  var Id = "";
  var isChecked = false;
  if(allRows.length > 0)
  {
    ko.utils.arrayForEach(allRows, function(eachRow)
                          {
      isChecked = $(eachRow).find('input:checkbox:first').prop('checked');

      if(isChecked)
      {        
        Id +=$(eachRow).find("JobId").text()+ "," ;   
                var gridControl = control.findById("G1");
        var rowData = SFU.getGridValue(gridControl);
        //control.findByXmlNode("Textinput1").value = rowData.Tag;   
        Id += rowData[0].vwApproveCnS.JobID + ",";
      }   
     
    });
    Id = Id.substr(1);

    if(control.findById("T1").value !== Id)
    {
        control.findById("T1").value = Id;  
    }
   
  }

}

if(isChecked)
{
  
  control.findByXmlNode("isSelected").value="1";
}
else
{
  control.findByXmlNode("isSelected").value="0";
}

//----------------------------------------------------------


if (control.findByXmlNode("isSelected").value=="1")
{
  control.findById("F2").visible=true;
  control.findById("F1").visible=true;
}

enter image description here




Change input with string of multiple checkbox values

I need to be able to set the onclick function without onclick being in the input tag. The below code works great, but the input tags are generated and I cannot add the onclick event to them. Jquery solution is fine too.

function setValue(){
   var val="";
   var frm = document.getElementById("form1");
   var cbs = document.getElementById("form1")['amenities[]'];
   for(var n=0;n<cbs.length;n++){
       if(cbs[n].checked){
           val+=cbs[n].value+",";
       }
   }
   var temp = val.split(",");
   temp.pop();
   frm.textname.value=temp
}
    
    <form id="form1">
    <input type="checkbox" name="amenities[]" value="coffee" onclick="setValue(this.value);">
    <input type="checkbox" name="amenities[]" value="tea" onclick="setValue(this.value);">
    <input type="checkbox" name="amenities[]" value="beer" onclick="setValue(this.value);">
    <input type="checkbox" name="amenities[]" value="soda" onclick="setValue(this.value);">
    <input type="checkbox" name="amenities[]" value="orangejuice" onclick="setValue(this.value);">
    <input type="text" name="textname">
    </form>



expo react native element echeckbox

I have some checkbox based value true/false is from sqlite database. with code below sqlite updated with i expected, i only have problem in state for checked={this.state.KUSENINS1}, checked={this.state.KUSENINS2} i got error, Failed prop type: Invalid prop checked of type string supplied to CheckBox, expected boolean. and checkbock alaways on checked/true even in my database value is false the checkbox keep on checked.Any help or link for the same problem.thxu

import Expo, { SQLite } from 'expo';
import React from 'react';
import { StyleSheet, Text, View, ScrollView, ActivityIndicator, SafeAreaView, AppRegistry } from 'react-native';
import { CheckBox } from 'react-native-elements';
import database from './database';

export default class AreaSpecify extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            isLoading: true,
            numberOfRefresh: 0,
            //checked: null,
            data: null,
            NO: null,
            NOKAMAR: null,
            NP: null,
            LT: null,
            KUSENINS1: false,
            KUSENINS2: false,
            KUSENINS3: false,
            KUSENINS4: false,
            KUSENFIN1: false,
            KUSENFIN2: false,
            KUSENFIN3: false,
            KUSENFIN4: false,
            KUSENFIN5: false,
        };
    }

    componentDidMount(){
        const { navigation } = this.props;
        var NO = navigation.getParam('NO');

        //var datas = projectData;
        database.transaction(
            tx => {
                tx.executeSql('select * from List where NO = ?', [NO], (_, { rows: { _array } }) =>
                    {
                        //var data = rows._array;

                        this.setState({
                            isLoading: false,
                            data: _array,
                            NO: _array[0].NO,
                            NOKAMAR: _array[0].NOKAMAR,
                            NP: _array[0].NP,
                            LT: _array[0].LT,
                            KUSENINS1: _array[0].KUSENINS1,
                            KUSENINS2: _array[0].KUSENINS2,
                            KUSENINS3: _array[0].KUSENINS3,
                            KUSENINS4: _array[0].KUSENINS4,
                            KUSENFIN1: _array[0].KUSENFIN1,
                            KUSENFIN2: _array[0].KUSENFIN2,
                            KUSENFIN3: _array[0].KUSENFIN3,
                            KUSENFIN4: _array[0].KUSENFIN4,
                            KUSENFIN5: _array[0].KUSENFIN5,
                        });
                        console.log(this.state.data);
                        console.log(this.state.KUSENINS2);


                    }
                );
            },
            null
        );

    }



    render() {

        if (this.state.isLoading){

                return (
                    <SafeAreaView style=>
                        <View style=>
                            <ActivityIndicator size="small" color="#f7c744"/> 
                        </View>
                    </SafeAreaView>
                )

            }else{

                console.log(this.state.numberOfRefresh);

                    return (
                    <View style=> 
                        <View style={styles.title}>
                            <Text style={styles.textTittle}>Project:{this.state.NP}</Text>
                            <Text style={styles.textTittle}>Area:{this.state.LT} | No.Kamar/Rumah:{this.state.NOKAMAR}</Text>
                        </View>
                        <ScrollView style=>
                        <View style=>
                            <Text style={styles.textTittle}>Instalasi Kusen</Text>
                        </View>
                        <View style={styles.row}>
                        <Text style={styles.text}>Selesai</Text>
                        <Text style={styles.text}>Control Job</Text>
                        </View>
                        <View style={styles.row}>
                            <CheckBox checked={this.state.KUSENINS1}
                            title='Konsistensi Leveling Kusen'
                            containerStyle=
                            onPress={() => {

                                var NO = this.state.NO;
                                var check = !this.state.KUSENINS1;
                                database.transaction(
                                tx => {
                                    tx.executeSql("update List set KUSENINS1 = '"+ check +"' where NO = '"+ NO +"';");
                                    this.setState({KUSENINS1:!this.state.KUSENINS1})
                                    console.log(NO, !this.state.KUSENINS1);
                                },
                                null
                                );

                            }}/>
                        </View>
                        <View style={styles.row}>
                            <CheckBox checked={this.state.KUSENINS2}
                            title='Lot sudah tegak lurus'
                            containerStyle=
                            onPress={() => {

                                var NO = this.state.NO;
                                var check = !this.state.KUSENINS2;
                                database.transaction(
                                tx => {
                                    tx.executeSql("update List set KUSENINS2 = '"+ check +"' where NO = '"+ NO +"';");
                                    this.setState({KUSENINS2:!this.state.KUSENINS2})
                                    console.log(NO, !this.state.KUSENINS2);
                                },
                                null
                                );

                            }}/>
                        </View>
                        </ScrollView>
                    </View>
                    );
        }

    }
}

And this data fetch from sqlite for a row

Array [
Object {
  "ARCDATE": "",
  "ARCHFIN1": "true",
  "ARCHFIN2": "true",
  "ARCHFIN3": "true",
  "ARCHFIN4": "true",
  "ARCHFIN5": "true",
  "ARCHINS1": "true",
  "ARCHINS2": "true",
  "ARCHITRAVE": "true",
  "DEFPINTULEBAR": 90,
  "DEFPINTUPANJANG": 200,
  "DOORSTOP": "false",
  "DSDATE": "",
  "ENDDATE": "2018-12-18T17:00:00.000Z",
  "GLOBALSTATUS": 0,
  "HANDATE": "",
  "HANDLE": "true",
  "KET": "",
  "KETARCHI": "",
  "KETDOORSTOP": "",
  "KETHANDLE": "",
  "KETKUSEN": "",
  "KETPINTU": "",
  "KUSDATE": "",
  "KUSEN": "true",
  "KUSENFIN1": "false",
  "KUSENFIN2": "true",
  "KUSENFIN3": "true",
  "KUSENFIN4": "true",
  "KUSENFIN5": "true",
  "KUSENGMBR": "",
  "KUSENINS1": "true",
  "KUSENINS2": "false",
  "KUSENINS3": "false",
  "KUSENINS4": "true",
  "LASTUPDATE": "2018-10-31T17:00:00.000Z",
  "LT": "1",
  "NO": 53,
  "NOKAMAR": 107,
  "NP": "Novotel",
  "PINTU": "true",
  "PINTUDATE": "",
  "PINTUFIN1": "true",
  "PINTUFIN2": "true",
  "PINTUFIN3": "true",
  "PINTUFIN4": "true",
  "PINTUFIN5": "true",
  "PINTUGMBR": "",
  "PINTUINS1": "true",
  "PINTUINS2": "true",
  "PINTUINS3": "true",
  "PINTUINS4": "true",
  "PINTUINS5": "true",
  "REV": "",
  "SEALENT": "true",
  "SEALENTRAPIH": "true",
  "STARTDATE": "2018-10-31T17:00:00.000Z",
  "STATUS": 0,
  "SUBKON": "SUBKON A",
  "UKURANPINTUST": 0,
  "UPINTULEBAR": 90,
  "UPINTULEBAR2": 90,
  "UPINTULEBAR3": 90,
  "UPINTUPANJANG": 200,
},
]