vendredi 31 mai 2019

Why I can't checked more than checkboxes?

Using Flask I populated a table and tried to create something which made it possible for clicking in any part of row and "checked" the checkbox input. But I can't checked more than one.

Created a var to check if the input is "checked", if no, checked! if yes, make possible unchecked the box at any part of tr.

  $("table tbody tr").on('click',function(){
    var checked = $("input:checkbox").is(':checked');
    if(checked){
     $("input:checkbox",this).prop('checked', false);
     console.log(checked);      
    }else{
     console.log(checked);
     $("input:checkbox",this).prop('checked', true);
    }

HTML:

<table class="table table-responsive" id="osTable" width="100%" cellspacing="0" align="center">
        <thead align="center">
            <tr>
             <th>#</th>         
             <th>Id</th>        
             <th>Name</th>                                                  
            </tr>
        </thead>
        <tbody>
         
        </tbody>        
    </table>




How do you get a switch statement in android to recognize a checkbox?

I would like to clean up my code and have my checkbox do some actions from the switch statement inside onOptionsItemSelected(). Instead, I have an onClick listener in onCreateOptionsMenu for my custom checkbox. This works, but I would like to understand how to have code inside case R.id.star_favorite: called.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    checkBox = (CheckBox) menu.findItem(R.id.star_favorite).getActionView();
    checkBox.setButtonDrawable(R.drawable.favorite_checkbox);
    if(currentQuote != null) {
        currentQuoteIsFavorite = currentQuote.getFavorite();
        checkBox.setChecked(currentQuoteIsFavorite);
    }
    checkBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if(currentQuote != null) {
                currentQuoteIsFavorite = !currentQuoteIsFavorite;
                updateFavorite(currentQuoteIsFavorite);
            } else {
                checkBox.setChecked(false);
                Toast.makeText(getApplicationContext(), "No Quote To Save", Toast.LENGTH_SHORT).show();
            }
        }
    });
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.star_favorite:
            //already tried putting code like updateFavorite() inside here but it's not called
            Toast.makeText(this, "Checkbox clicked", Toast.LENGTH_SHORT).show();
            if(currentQuote != null) {
                currentQuoteIsFavorite = !currentQuoteIsFavorite;
                updateFavorite(currentQuoteIsFavorite);
            } else {
                checkBox.setChecked(false);
                Toast.makeText(getApplicationContext(), "No Quote To Save", Toast.LENGTH_SHORT).show();
            }
        case R.id.share_quote:
            Log.d("onOptionsItemSelected", "case R.id.share_quote selected");
            shareQuote();
            break;
        case R.id.menu:
            Log.d("onOptionsItemSelected", "case R.id.menu selected");

            break;
    }
    return super.onOptionsItemSelected(item);
}




DataBinding to a checkbox not working correctly

I have a problem using DataBinding to a checkbox in C#. Checkbox does not reflect the value of the object it is bind to.

I used "checkBox1.DataBindings.Add("Checked", cb, "t", false, DataSourceUpdateMode.OnPropertyChanged)" to bind a simple data source to an object, cb. The the bool property "t" in the object updates based on the checkbox checked state, but the checkbox check state does not reflect the object state (cb.t).

namespace WindowsFormsApplication1 { public partial class Form1 : Form { test cb = new test(); public Form1() { InitializeComponent();

        cb.t = false;

        checkBox1.DataBindings.Add("Checked", cb, "t", false, DataSourceUpdateMode.OnPropertyChanged);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        cb.t = true;
        //checkBox1.Refresh();
        //checkBox1.Invalidate();
    }
}

public class test
{
    public bool t { set; get; }
}

}

if i click button1 the state of the checkbox does not change; however, the if i i set the cb.t = true in the constructor when the form loads the checkbox checked state is the same as the value of cb.t. thanks for the help.




Checkbox required

I have this code for a newsletter block in my site, a specific CMS:

<!-- newsletter block -->

{if $tpl_settings.type == 'responsive_42'}{strip}
        <div class="subscribe{if $block.Side != 'left' && $block.Side != 'right'} light-inputs{/if}">
                <div id="nl_subscribe">
                        <input placeholder="{$lang.massmailer_newsletter_your_name}" type="text" id="newsletter_name" maxlength="50" />
                        <input placeholder="{$lang.massmailer_newsletter_your_e_mail}" type="text" id="newsletter_email" maxlength="100" />

                        <br />
                        <label><input type="checkbox" id="newsletter_privacy" /></label> <a href="#">Privacy Policy</a>.
                        <br />
                        <br />

                        <input class="low" onclick="xajax_subscribe('subscribe', $('#newsletter_name').val(), $('#newsletter_email').val());$(this).val('{$lang.loading}');" type="button" value="{$lang.massmailer_newsletter_subscribe}"/>

                        <div class="nav-link"><span id="unsubscribe_link" class="link">{$lang.massmailer_newsletter_unsubscribe}</span></div>
                </div>
                <div id="nl_unsubscribe" class="hide">
                        <input placeholder="{$lang.massmailer_newsletter_your_e_mail}" type="text" id="un_newsletter_email" maxlength="50" />
                        <input class="low" onclick="xajax_subscribe('unsubscribe', '', $('#un_newsletter_email').val());$(this).val('{$lang.loading}');" type="button" value="{$lang.massmailer_newsletter_unsubscribe}"/>
                        <div class="nav-link"><span id="subscribe_link" class="link">{$lang.massmailer_newsletter_subscribe}</span></div>
                </div>
        </div>
{/strip}{else}
        <div id="nl_subscribe">
                {$lang.massmailer_newsletter_your_name}
                <div style="padding: 0 0 5px;"><input type="text" id="newsletter_name" maxlength="150" style="width: 80%;" /></div>
                
                {$lang.massmailer_newsletter_your_e_mail}
                <div><input type="text" id="newsletter_email" maxlength="100" style="width: 80%" /></div>
                
                <div style="padding: 10px 0 0;">
                        <input onclick="xajax_subscribe('subscribe', $('#newsletter_name').val(), $('#newsletter_email').val());$(this).val('{$lang.loading}');" type="button" value="{$lang.massmailer_newsletter_subscribe}"/>
                </div>
                <div style="padding: 5px 0">
                        <a id="unsubscribe_link" href="javascript:void(0);" class="static">{$lang.massmailer_newsletter_unsubscribe}</a>
                </div>
        </div>
        <div id="nl_unsubscribe" class="hide">
                {$lang.massmailer_newsletter_your_e_mail}
                <div><input type="text" id="un_newsletter_email" maxlength="150" style="width: 80%" /></div>
                <div style="padding: 10px 0 0;">
                        <input onclick="xajax_subscribe('unsubscribe', '', $('#un_newsletter_email').val());$(this).val('{$lang.loading}');" type="button" value="{$lang.massmailer_newsletter_unsubscribe}"/>
                </div>
                <div style="padding: 5px 0">
                        <a id="subscribe_link" href="javascript:void(0);" class="static">{$lang.massmailer_newsletter_subscribe}</a>
                </div>
        </div>
{/if}

<script type="text/javascript">
{literal}
$(document).ready(function(){
        $('#unsubscribe_link').click(function(){
                $('#nl_subscribe').slideUp('normal');
                $('#nl_unsubscribe').slideDown('slow');
        });
        $('#subscribe_link').click(function(){
                $('#nl_unsubscribe').slideUp('normal');
                $('#nl_subscribe').slideDown('slow');
        });
});
{/literal}
</script>

<!-- newsletter block end -->

I can't enforce the "required" checkbox via JavaScript/Ajax, can you please help me to change the code correctly?

I'm not managing to make it work because the "form" tag is missing like any normal form.

Thanks!




Is there a way to make an indeterminate checkbutton with PyGtk?

I am designing a GUI where I have a list of checkable items that also has a sublist of checkable items. I want to graphically represent in the parent checkbox if only some of the child items are checked. I have been searching Google for hours with this and the only documents explain how to style a possible button. Is there a way in Gtk to do this cleanly?




Drupal checkbox required

I'm using Drupal 6, in the Newsletter box I can get the privacy checkbox to appear, unfortunately it appears after the Submit button, and this is the first problem.

The second problem is that after push Submit, the "required" is not respected.

<?php
// $Id: simplenews-block.tpl.php,v 1.1.2.5 2009/01/02 11:59:33 sutharsan Exp $

/**
 * @file
 * Default theme implementation to display the simplenews block.
 * 
 * Copy this file in your theme directory to create a custom themed block.
 * Rename it to simplenews-block--<tid>.tpl.php to override it for a 
 * newsletter using the newsletter term's id.
 *
 * Available variables:
 * - $subscribed: the current user is subscribed to the $tid newsletter
 * - $user: the current user is authenticated
 * - $tid: tid of the newsletter
 * - $message: announcement message (Default: 'Stay informed on our latest news!')
 * - $form: newsletter subscription form *1
 * - $subscription_link: link to subscription form at 'newsletter/subscriptions' *1
 * - $newsletter_link: link to taxonomy list of the newsletter issue *2
 * - $issuelist: list of newsletters (of the $tid newsletter series) *2
 * - $rssfeed: RSS feed of newsletter (series) *2
 * Note 1: requires 'subscribe to newsletters' permission
 * Note 2: requires 'view links in block' or 'administer newsletters' permission
 *
 * Simplenews module controls the display of the block content. The following
 * variables are available for this purpose:
 *  - $use_form       : TRUE = display the form; FALSE = display link to example.com/newsletter/subscriptions
 *  - $use_issue_link : TRUE = display link to newsletter issue list
 *  - $use_issue_list : TRUE = display list of the newsletter issue
 *  - $use_rss        : TRUE = display RSS feed
 *
 * @see template_preprocess_simplenews_block()
 */
?>
  <?php if ($message): ?>
    <p><?php print $message; ?></p>
  <?php endif; ?>

  <?php if ($use_form): ?>
    <?php print $form; ?>

  <label><input type="checkbox" id="privacy" required /></label> <a href="#">Terms and conditions</a>

  <?php elseif ($subscription_link): ?>
    <p><?php print $subscription_link; ?></p>
  <?php endif; ?>

  <?php if ($use_issue_link && $newsletter_link): ?>
    <div class="issues-link"><?php print $newsletter_link; ?></div>
  <?php endif; ?>

  <?php if ($use_issue_list && $issue_list): ?>
    <div class="issues-list"><?php print $issue_list; ?></div>
  <?php endif; ?>

  <?php if ($use_rss): ?>
    <?php print $rssfeed; ?>
  <?php endif; ?>



how to map an array of objects which has another array to checkboxes in angular 4

I have this array of objects. In each object there is another array.

panels = [{
  Id: "26cfdb68-ef69-4df0-b4dc-5b9c6501b0dd",
  Name: "Celiac test",
  Tests: [{
      Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
      Name: "test 1 (DGP) IgG"
    },
    {
      Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
      Name: "test 2 (DGP) IgG"
    },
    {
      Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
      Name: "test 3 (DGP) IgG"
    }
  ]
}],

PS: there is no checked flag coming from backend

I have mapped it to a bootstrap accordion with checkboxes.

First there is a checkbox for the main object, then checkboxes for the array within that object.

What I want is that when I click on the main Panel checkbox it should select the Tests checkboxes and save the panel object in the object variable, say selectedPanel, and when I deselect the main Panel it should deselect all the Tests checkboxes too.

and the main thing is that when I deselect one of the Tests checkboxes it should be removed from selectedPanel but dont remove it from front-end.

Can anyone help me in this regard?

I have created a stackblitz too:

Stackblitz




Checkbox value is always empty even if i check it

I made a button to delete files from a database, to delete a file you need to check a checkbox and then click a button. somewhy when i click the button and write the checkbox value to the html it always says false...

ASPX:

<asp:GridView HorizontalAlign="Center" ID="GridView1" runat="server" class="" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Horizontal" DataKeyNames="ID">
    <Columns>
        <asp:TemplateField HeaderText="Name">< ItemTemplate >
                            < asp:LinkButton ID = "LinkButton2" runat="server" OnClick="OpenDocument" Text='<%# Eval("File_Name") %>'></asp:LinkButton>
                        </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Delete?">< ItemTemplate >
                            < asp:CheckBox ID = "CheckBox1" runat="server" />
                        </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<asp:Button runat="server" Text="Update" ID="Update" class="button" OnClick="UpdateTable" Style="font-size: 20px" />

Code Behind:

protected void UpdateTable(object sender, EventArgs e)
{
    foreach (GridViewRow item in GridView1.Rows)
    {
        CheckBox chk = (CheckBox)item.FindControl("CheckBox1");
        if (chk != null)
        {
            //This is being written and always false
            Response.Write(chk.Checked);
            if (chk.Checked)
            {
               //Delete the item. (never being executed)
            }
        }
    }
}

I expected chk.Checked to be True since i've clicked it...




jeudi 30 mai 2019

Material-UI checkbox backrground color

I am using material ui checkbox, i wanted it to have its own background color over my div which has colored background. I have set the root to have a backgroundColor as white but the svgicon is a round shape which is not the look i intend to have. Can i shape the checkbox ?

Already have tried many things but not able to figure out how to change the icon

const styles = {
    root : {
        padding : '0px',
        display : 'inline-block',
        backgroundColor : 'white'
    },
    formLabelRoot : {
        margin : '0'
    }
}
.
.
.
render () {
        const { classes } = this.props
        return(
            <div style={customStyles.divStyle}>
                <div style={customStyles.div1}>
                    <FormControlLabel
                        classes=
                        control={
                            <Checkbox
                                classes=
                                color='primary'
                            />
                            }
                        label={''}
                    />
                </div>

The background white is making a spherical rounded checkbox apparent

Image of what is happening now




React: How to add onChange functionality inside of Function component? Need onClick event from a checkbox to influence input state

I have a functional component with a checkbox and an input. I'm trying to create an onChange function for the checkbox that clears the input and disables it whenever a user clicks it.

Additionally I'm also trying to add functionality to the input so that a user can delete the pre existing value and type something new. I know that you would typically achieve this with a class component but I'm wondering if there's any way to achieve this within a function component? I have my current component listed below

import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
import {
  Col, Row, Icon, Input, Tooltip
} from 'antd'
import Checkbox from '../elements/Checkbox'

const CustomerDetails = ({ customer }) => {
  if (customer === null) {
    return (
      <Container>
        <Row>
          <Col span={24}>
            <ErrorContainer>
              <Icon type="exclamation-circle" />
            </ErrorContainer>
          </Col>
        </Row>
      </Container>
    )
  }

  return (
    <Container>
      <h2>{customer.contact.name}</h2>
      <Row>
        <Col span={8}>
          <H3>
            <strong>Primary Contact:</strong>
          </H3>
          <P>{customer.contact.name}</P>
          <P>{customer.contact.phone}</P>
        </Col>
        <Col span={8}>
          <H3>
            <strong>Service Address:</strong>
          </H3>
          <P>{customer.site.address1}</P>
          <P>{customer.site.address2}</P>
          <P>
            {customer.site.city},&nbsp;{customer.site.state}&nbsp;
            {customer.site.postalCode}
          </P>
        </Col>
        <Col span={8}>
          <H3>
            <strong>Billing Address:</strong>
          </H3>
          <P>{customer.account.billingStreet}</P>
          <P>
            {customer.account.billingCity},&nbsp;{customer.account.billingState}
            &nbsp;
            {customer.account.billingPostalCode}
          </P>
        </Col>
      </Row>
      <br />
      <Row>
        <Col span={10}>
          <h4>
            PRIMARY CONTACT EMAIL &nbsp;
            <Tooltip
              placement="topRight"
              title={primaryContact}
            >
              <StyledTooltipIcon
                type="question-circle"
                theme="filled"
              />
            </Tooltip>
          </h4>
        </Col>
      </Row>
      <Row>
        <Col span={8}>
          <StyledInput value={customer.contact.email} />
        </Col>
        <Col span={2} />
        <Col span={8}>
          <StyledCheckbox /> EMAIL OPT OUT{' '}
          <Tooltip
            placement="topRight"
            title={emailText}
          >
            <StyledTooltipIcon
              type="question-circle"
              theme="filled"
            />
          </Tooltip>
        </Col>
      </Row>
    </Container>
  )
}

CustomerDetails.propTypes = {
  customer: PropTypes.object
}

CustomerDetails.defaultProps = {
  customer: {}
}

const Container = styled.div`
  text-align: left;
`
const StyledCheckbox = styled(Checkbox)`
  input + span {
    border-radius: 0px;
    width: 35px;
    height: 35px;
    border: 2px solid ${({ theme }) => theme.colors.black};
    background-color: transparent;
    color: ${({ theme }) => theme.colors.black};
    border-color: ${({ theme }) => theme.colors.black};
    transition: none;
  }

  input:checked + span {
    border: 2px solid ${({ theme }) => theme.colors.black};
    width: 30px;
    height: 30px;
  }

  input + span:after {
    border-color: ${({ theme }) => theme.colors.black};
    left: 20%;
    transition: none;
    width: 12.5px;
    height: 20px;
  }

  input:disabled + span:after {
    border-color: ${({ theme }) => theme.colors.gray};
  }

  input:not(:checked):hover + span:after {
    border-color: ${({ theme }) => theme.colors.gray};
    opacity: 1;
    transform: rotate(45deg) scale(1) translate(-50%, -50%);
  }

  input:focus + span {
    border-color: ${({ theme }) => theme.colors.primary};
  }
`

const StyledInput = styled(Input)`
  max-width: 100%;

  &&& {
    border: 2px solid ${({ theme }) => theme.colors.black};
    border-radius: 0px;
    height: 35px;
  }
`

const ErrorContainer = styled.div`
  /* margin-left: 25%; */
`

const StyledTooltipIcon = styled(Icon)`
  color: #1571da;
`

const H3 = styled.h3`
  white-space: nowrap;
  margin-top: 0;
  margin-bottom: 0;
  line-height: 1.5;
}
`

const H4 = styled.h4`
  text-decoration: underline;
  color: #1590ff;
`

const P = styled.p`
  margin-top: 0;
  margin-bottom: 0;
  font-size: 1rem;
`

export default CustomerDetails





Angular: why does my mat-checkbox does not show as checked after single click?

I have an Angular application with a checkbox list (mat-checkbox) that is properly displaying the English or Spanish values depending on locale.

Problem: However, the checkbox itself is not consistently being checked when the user clicks on it. It takes multiple tries (no specific amount). What could cause something like this?

I've tried:

  • I have looked into [checkex] and (change).
  • I have tried changing my objects/class/interface.
  • I've looked through Angular documentation.
  • I've done console.log on everything I could find
  • I've looked through SO articles such as: Mat-checkbox checked not changing checkbox state

component.html:

<div class="student-history-checkbox" *ngFor="let item of gradesInCurrentLanguage()">
    <mat-checkbox [checked]="isChecked(item.ID)" (change)="onChangeCB($event, item.ID)"></mat-checkbox>
</div>

component.ts:

public gradesInCurrentLanguage() : CGenericRecord[] {
    return this.ms.XFormForLocale(this.grades, this.localeId);
}


isChecked(ID : number)
{
    return (this.gradeInfo.Grades.indexOf(ID) > -1) ? true : false;
}



onChangeCB(event : any, id : number)
{
    if(event.checked && this.gradeInfo.Grades.indexOf(id) == -1){
        this.gradeInfo.Grades.push(id);
    }else{
        let index = this.gradeInfo.Grades.indexOf(id);
        this.gradeInfo.Grades.splice(index, 1);
    }       
}

Didn't want to make this post too long, but I can provide service and interface code as well if needed.

Expected result: Checkbox should show that it is checked when the user clicks on it once. It should also show that it is unchecked after one click.

Actual result: Checkbox is only checked after multiple clicks




I want checkbox swatches in variants anyone can help me

Shopify Checkbox Swatches I want checkbox swatches in variants anyone can help me. in the Shopify product page. anyone know which "js" I have to use. or any plugin




multiple checkboxes with paging in php without using javascript and jquery

Good day I have an html table and I use paging on it so that only certain amount of items is shown. The problem is that I need to have a multiple selection with checkboxes and that works for a single page but I need that to work between pages. So for example on page 1 you choose 3 items and in the next page you choose 5 items and when GET happens I need to have all those items in one place so that I can store them in a variable.

<?php
session_start();
?>
<html>
    <body>

    <?php
    include("connect.php");     //database connection file
    $limit = 7;
        if ( isset($_GET['page']) ) {
            $page_no = $_GET['page'];
        } else {
            $page_no = 1;
        }
        $start_from = ($page_no-1)*$limit;
        $sql = "SELECT * FROM emp_info LIMIT $start_from,$limit ";
        $result = mysqli_query($conn , $sql);
    ?>

        <form method="GET" action="project.php?name=<?php echo 
$data['name']; ?>">
            <div class="container">
                <h2>employee information:</h2>
                <table class="table table-striped table-hover">
                    <thead>
                        <tr>
                            <th>EmpId</th>
                            <th>Name</th>
                            <th>Email</th>      
                        </tr>
                    </thead>
                    <tbody>

                    <?php
                    $info = "SELECT * 
                        FROM emp_info LIMIT $start_from,$limit ";           
//query to select the data from database
                    $query = mysqli_query ($conn , $info);
                    while ( $data = mysqli_fetch_assoc ($query) ) 
{       //query to fetch the data
                        $_SESSION['emp_name']=$data['name'];
                        ?>  <tr> 
                            <td><?php echo $data['emp_id'];?></td>
                            <td><a href="project.php?id=<?php echo 
$data['emp_id'];?>&name=<?php echo $data['name']; ?>"> <input 
type="checkbox" name="check_list[]" value="<?php echo 
$data['name'];?>"> </a> <?php echo $data['name'];?></td>  
                            <td><?php echo $data['email'];?></td>           

                        </tr>
                    <?php           }
            ?>
                    </tbody>            
                </table>
                <ul class="pagination"> 
                <?php   
                        $sql = "SELECT COUNT(*) FROM emp_info";   
                        $result = mysqli_query($conn , $sql);   
                        $row = mysqli_fetch_row($result);   
                        $total_records = $row[0];   
                        // Number of pages required. 
                        $total_pages = ceil($total_records / 
$limit);   
                        $pagLink = "";                         
                        for ( $i = 1; $i <= $total_pages; $i++) { 
                            if ( $i == $page_no) { 
                                    $pagLink .= "<p>Pages:</p><li 
class='active'><a href='datatable.php?id=" . $data['emp_id'] . 
"&page=" . $i ."'>". $i ."</a></li>";

                        } else  { 
                            $pagLink .= "<li><a 
href='datatable.php?page=". $i ."'>". $i ."</a></li>";   
                        } 
                    };   
                        echo $pagLink;    
                ?> 
                </ul> 
            </div>
            &nbsp; <button type="submit" formaction="project.php" 
name="select_proj">Select Project</button>
            &nbsp; <button type="submit" 
formaction="addnewproj.php"  name="add_proj">Add New 
Project</button>
        </form>
    </body>
</html>




deselecting checkbox is removing whole row from the front-end angular 4

i have this Panel array coming from backend which has another array Tests. i have mapped them on my custom accordion with checkboxes. the problem i am facing is i should be able to select/deselect Tests without removing it from the from front-end like it Disappears when i deselect. how can i solve this issue?

you can see from that image

https://i.stack.imgur.com/qJUFy.png

here is my html file

<ngb-panel *ngFor="let panel of panels" id="" [title]="panel.Name">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" [name]="panel.Id + '-' + panel.Moniker" [ngModel]="checkAllTestsSelected(panel)"
  (ngModelChange)="onPanelCheckboxUpdate($event, panel)" [id]="panel.Id + '-' + panel.Moniker">
 <span class="custom-control-indicator"></span>
 </label>

</ng-template>
<ng-template ngbPanelContent>
<div class="individual-panel" *ngFor="let test of panel.Tests">
<span class="text-dimmed"></span>
<span *ngIf="panel.Name.includes('ENA') || panel.Name.includes('Celiac')">
<label class="custom-control custom-checkbox">
 <input type="checkbox" class="custom-control-input" [name]="test.Id + '-' + test.Code"
       [ngModel]="testSelectionSession.SelectedPanelIds.indexOf(panel.Id) > -1 || testSelectionSession.SelectedPanelIds.indexOf(test.AssociatedPanel?.Id) > -1"
       (ngModelChange)="onTestCheckboxUpdate($event, test, panel)" 
  [id]="test.Id + '-' + test.Code">
  <span class="custom-control-indicator"></span>
  </label>
  </span>
  </div>

ts file

 checkAllTestsSelected(panel: TestOrderPanel) {
 // get all individual test panels
 let individualTestPanelIds = panel.Tests.reduce((acc, test) => {
 if (test.AssociatedPanel) {
 acc.push(test.AssociatedPanel.Id);
 }
 return acc;
 }, []);

// check if all individual test panels are selected

let allIndividualTestsSelected = individualTestPanelIds.reduce(
(acc: boolean, panelId: number) =>
 acc && this.panelIds.indexOf(panelId) > -1,
 individualTestPanelIds.length > 0 &&
 panel.Tests.length === individualTestPanelIds.length
 );

 // if selected, remove all individual test panels and add the panel group
 if (panel.Tests.length > 0 && allIndividualTestsSelected) {
 this.panelIds = this.panelIds.filter(
 panelId => individualTestPanelIds.indexOf(panelId) === -1
 );
  this.selectedPanels = this.selectedPanels.filter(
  selectedPanel => individualTestPanelIds.indexOf(selectedPanel.Id) === -1
  );
  this.panelIds.push(panel.Id);
  this.selectedPanels.push(panel);
  this.updateSession();
  }
  return this.panelIds.indexOf(panel.Id) > -1;
  }


 onPanelCheckboxUpdate($event: boolean, panel: TestOrderPanel) {
 let testPanelIds = panel.Tests.reduce((acc, test) => {
  if (test.AssociatedPanel) {
  acc.push(test.AssociatedPanel.Id);
 }

  return acc;
  }, []);

  // Wipe any duplicates
  this.panelIds = this.panelIds.filter(
  panelId => panel.Id !== panelId && testPanelIds.indexOf(panelId) === -1
  );
 this.selectedPanels = this.selectedPanels.filter(
 selectedPanel =>
 panel.Id !== selectedPanel.Id &&
 testPanelIds.indexOf(selectedPanel.Id) === -1
 );

 if ($event) {
 this.panelIds.push(panel.Id);
 this.selectedPanels.push(panel);
 }
 this.updateSession();
 }

 onTestCheckboxUpdate($event: boolean,
               test: TestOrderPanelTest,
               panel: TestOrderPanel,
               index) {

 let testPanelIds = panel.Tests.reduce((acc, test) => {
 if (test.AssociatedPanel) {
 acc.push(test.AssociatedPanel.Id);
 }

 return acc;
 }, []);
 let associatedTestPanels = 
 this.testSelectionSession.IndividualTestPanelsForAll.filter(
 testPanel => testPanelIds.indexOf(testPanel.Id) > -1
 );
 // If the panel is selected and a test within the panel is deselected,
 // remove the panel and back all of the individual tests
  if (this.panelIds.indexOf(panel.Id) > -1 && !$event) {
  this.selectedPanels = this.selectedPanels.filter(
  e => e.Tests.splice(index, 1)
   );
  }

  let clickedTestPanel = associatedTestPanels.find(
  testPanel => (test.AssociatedPanel ? test.AssociatedPanel.Id : -1) === 
  testPanel.Id
  );

 if (clickedTestPanel) {
 // Wipe any duplicates
 this.panelIds = this.panelIds.filter(
 panelId => clickedTestPanel.Id !== panelId
 );
 this.selectedPanels = this.selectedPanels.filter(
 panel => clickedTestPanel.Id !== panel.Id
 );

 // Add individual panel if checkbox selected
 if ($event) {
  this.panelIds = this.panelIds.concat(clickedTestPanel.Id);
  this.selectedPanels = this.selectedPanels.concat(clickedTestPanel);
  }
   }
 this.updateSession();
 }

this.panelIds includes IDs of panels and this.selectedPanels includes whole panel array which is selected.

i have created a stackblitz too

my code is doing something like that stackblitz.com/edit/angular-bsszc9

and here is example of how my page will look like stackblitz

how can i solve this problem? thanks




React Material UI Checkbox: How to check/uncheck other boxes in group by checking a different box?

I have 3 checkboxes set up, (Not Started, In Progress, Completed), that I would like allow only one to be checked at a certain time.

So if Not Started is automatically checked to begin with, how would I cause it uncheck 'Not Started' if I check 'Completed'?

Heres my code for now:

In App.js:

  const newGame = {
     id: uuid.v4(),
     title: title,
     hours: hours,
     notStarted: true,
     inProgress: false,
     completed: false,

  }

  notStarted = (id) => {
    this.setState({games: this.state.games.map(game => {
      if(game.id === id){

        game.notStarted = !game.notStarted
        game.inProgress = false;
        game.completed = false;
      }
    return game;
  })})
};

  markCompleted = (id) => {
this.setState({games: this.state.games.map(game => {
  if(game.id === id){

    game.completed = !game.completed
    game.notStarted = false;
    game.inProgress = false;
  }
  return game;
})})
};

And in the render() method:

<Backlog games={this.state.games} 
        markCompleted={this.markCompleted} 
        inProgress={this.inProgress}
        notStarted={this.notStarted}
/>

And this is the checkboxes in Game.js

<FormControlLabel
      control={
         <Checkbox
              color="primary"
              onChange={this.props.notStarted.bind(this, id)}
          />
      }
      label="Not Started"
/>
<FormControlLabel
      control={
         <Checkbox
              color="primary"
              onChange={this.props.markCompleted.bind(this, id)}
          />
      }
      label="Completed"
/>

As of now, I can successfully change the state of the props, but I'm unsure how to make the box check/uncheck according to the state?




mercredi 29 mai 2019

deselecting checkbox is removing whole row from the array mapped angular 4

i have this Panel array coming from backend which has another array Tests. i have mapped them on my custom accordion with checkboxes. the problem i am facing is i should be able to select/deselect Tests without removing it from the from front-end like it Disappears when i deselect. how can i solve this issue?

you can see from that image

https://i.stack.imgur.com/qJUFy.png

**here is my html file**

<ngb-panel *ngFor="let panel of panels" id="" [title]="panel.Name">
<label class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input" [name]="panel.Id + '-' + panel.Moniker" [ngModel]="checkAllTestsSelected(panel)"
      (ngModelChange)="onPanelCheckboxUpdate($event, panel)" [id]="panel.Id + '-' + panel.Moniker">
    <span class="custom-control-indicator"></span>
  </label>

 </ng-template>
 <ng-template ngbPanelContent>
<div class="individual-panel" *ngFor="let test of panel.Tests">
  <span class="text-dimmed"></span>
  <span *ngIf="panel.Name.includes('ENA') || panel.Name.includes('Celiac')">
  <label class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input" [name]="test.Id + '-' + test.Code"
           [ngModel]="testSelectionSession.SelectedPanelIds.indexOf(panel.Id) > -1 || testSelectionSession.SelectedPanelIds.indexOf(test.AssociatedPanel?.Id) > -1"
           (ngModelChange)="onTestCheckboxUpdate($event, test, panel)" [id]="test.Id + '-' + test.Code">
    <span class="custom-control-indicator"></span>
  </label>
  </span>
</div>

ts file

checkAllTestsSelected(panel: TestOrderPanel) {
  // get all individual test panels
  let individualTestPanelIds = panel.Tests.reduce((acc, test) => {
   if (test.AssociatedPanel) {
    acc.push(test.AssociatedPanel.Id);
  }
  return acc;
}, []);

// check if all individual test panels are selected
let allIndividualTestsSelected = individualTestPanelIds.reduce(
  (acc: boolean, panelId: number) =>
    acc && this.panelIds.indexOf(panelId) > -1,
  individualTestPanelIds.length > 0 &&
  panel.Tests.length === individualTestPanelIds.length
);

// if selected, remove all individual test panels and add the panel group
if (panel.Tests.length > 0 && allIndividualTestsSelected) {
  this.panelIds = this.panelIds.filter(
    panelId => individualTestPanelIds.indexOf(panelId) === -1
  );
  this.selectedPanels = this.selectedPanels.filter(
    selectedPanel => individualTestPanelIds.indexOf(selectedPanel.Id) === -1
  );
  this.panelIds.push(panel.Id);
  this.selectedPanels.push(panel);
  this.updateSession();
 }
  return this.panelIds.indexOf(panel.Id) > -1;
  }


 onPanelCheckboxUpdate($event: boolean, panel: TestOrderPanel) {
   let testPanelIds = panel.Tests.reduce((acc, test) => {
    if (test.AssociatedPanel) {
    acc.push(test.AssociatedPanel.Id);
  }

  return acc;
}, []);
// Wipe any duplicates
this.panelIds = this.panelIds.filter(
  panelId => panel.Id !== panelId && testPanelIds.indexOf(panelId) === -1
);
this.selectedPanels = this.selectedPanels.filter(
  selectedPanel =>
    panel.Id !== selectedPanel.Id &&
    testPanelIds.indexOf(selectedPanel.Id) === -1
);

if ($event) {
  this.panelIds.push(panel.Id);
  this.selectedPanels.push(panel);
   }
   this.updateSession();
 }

 onTestCheckboxUpdate($event: boolean,
                   test: TestOrderPanelTest,
                   panel: TestOrderPanel,
                   index) {

let testPanelIds = panel.Tests.reduce((acc, test) => {
  if (test.AssociatedPanel) {
    acc.push(test.AssociatedPanel.Id);
  }

  return acc;
}, []);
let associatedTestPanels = this.testSelectionSession.IndividualTestPanelsForAll.filter(
  testPanel => testPanelIds.indexOf(testPanel.Id) > -1
);
// If the panel is selected and a test within the panel is deselected,
// remove the panel and back all of the individual tests
if (this.panelIds.indexOf(panel.Id) > -1 && !$event) {
  this.selectedPanels = this.selectedPanels.filter(
    e => e.Tests.splice(index, 1)
  );
}

let clickedTestPanel = associatedTestPanels.find(
  testPanel => (test.AssociatedPanel ? test.AssociatedPanel.Id : -1) === testPanel.Id
);

if (clickedTestPanel) {
  // Wipe any duplicates
  this.panelIds = this.panelIds.filter(
    panelId => clickedTestPanel.Id !== panelId
  );
  this.selectedPanels = this.selectedPanels.filter(
    panel => clickedTestPanel.Id !== panel.Id
  );

  // Add individual panel if checkbox selected
  if ($event) {
    this.panelIds = this.panelIds.concat(clickedTestPanel.Id);
    this.selectedPanels = this.selectedPanels.concat(clickedTestPanel);
  }
}
  this.updateSession();
}

this.panelIds includes IDs of panels and this.selectedPanels includes whole panel array which is selected.

i have created a stackblitz too

stackblitz

can someone help? Thanks




Java Spring with thymeleaf checkbox non checked is Empty instead of false

I have checkbox inside of my form :

  <div class="form-check form-check-inline">
                        <input type="checkbox" th:field="${search.titleIncl}" />
                        <label class="form-check-label" th:for="${#ids.next('covered')}">Title</label>
                    </div>

This checkbox by default should be on since search object has this value assigned as true. This works fine. What i expected from thsi checkbox is to send either true or false when its checked/unchecked. What i got now is True if its checked and nothing when not checked. That his a bit of an issue for me :

In controller:

@GetMapping(value = Utils.MAPPING_INDEX)
public ModelAndView index(@RequestParam("titleIncl") Optional<Boolean> titleIncl) {
    ...calling fillSearch inside of body....
}


private Search fillSearch(Optional<Boolean> titleIncl..) {

        Search search = new Search();

        //Get seach value if nothing provided give me default.
        search.setTitleIncl(titleIncl.orElse(search.isTitleIncl()));
        ...

        return search;
}

Whole point of this form is to get user select what parts of the object he wants to search : enter image description here

So if he unselects checkbox and i dont send FALSE in optional, I run into problem.

When user initialy goes into the site, he doesnt send any of these parameters so it behaves fine by setting everything to true. Bud once he initiates search and deselects parts he doesnt wanna search in, he still ends up with defaults and searches in everything.

So is there a simple way of sending Optional FALSE if checkbox value is not selected?

Note :

  • By simple i mean without creating additional endpoint for this form search and no Javascript :)

  • And yes the form is under GET request




i have one problem with treeview with collapse button

i have some code for show a tree with list, and i need 2 button for expand and collapsed all of tree items, this button work correctly but have problem when i clicked on checkbox in my

  • tag,after that 2 button note work**`strong

if you check result code and use expand and collapse button you find my aim about problem

at first this button work very vell but when we clicked on checkbox,after that buttons not work at all

$(function () {

  //expand-collapse

$("#tree-collapse-all").click(function(){
    
    $(".tree input").removeAttr("checked");
  });
  $("#tree-expand-all").click(function(){
    $(".tree input").attr("checked","checked");
  });
});
      //# sourceURL=pen.js

  
 
  ol,ul{
    margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;
    list-style:none;
    }

  body {
  margin: 30px;
  font-family: sans-serif;
  }

#fontSizeWrapper { font-size: 16px; }

#fontSize {
  width: 100px;
  font-size: 1em;
  }

/* ————————————————————–
  Tree core styles
*/
.tree { margin: 1em; }

.tree input {
  position: absolute;
  clip: rect(0, 0, 0, 0);
  }

.tree input ~ ul { display: none; }

.tree input:checked ~ ul { display: block; }

/* ————————————————————–
  Tree rows
*/
.tree li {
  line-height: 1.2;
  position: relative;
  padding: 0 0 1em 1em;
  }

.tree ul li { padding: 1em 0 0 1em; }

.tree > li:last-child { padding-bottom: 0; }

/* ————————————————————–
  Tree labels
*/
.tree_label {
  position: relative;
  display: inline-block;
  background: #fff;
  }

label.tree_label { cursor: pointer; }

label.tree_label:hover { color: #666; }

/* ————————————————————–
  Tree expanded icon
*/
label.tree_label:before {
  background: #000;
  color: #fff;
  position: relative;
  z-index: 1;
  float: left;
  margin: 0 1em 0 -2em;
  width: 1em;
  height: 1em;
  border-radius: 1em;
  content: '+';
  text-align: center;
  line-height: .9em;
  }

:checked ~ label.tree_label:before { content: '–'; }

/* ————————————————————–
  Tree branches
*/
.tree li:before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -.5em;
  display: block;
  width: 0;
  border-left: 1px solid rgb(7, 240, 112);
  content: "";
  }

.tree_label:after {
  position: absolute;
  top: 0;
  left: -1.5em;
  display: block;
  height: 0.5em;
  width: 1em;
  border-bottom: 1px solid rgb(79, 7, 247);
  border-left: 1px solid rgb(240, 6, 6);
  border-radius: 0 0 0 .3em;
  content: '';
  }

label.tree_label:after { border-bottom: 0; }

:checked ~ label.tree_label:after {
  border-radius: 0 .3em 0 0;
  border-top: 1px solid rgb(79, 7, 247);
  border-right: 1px solid rgb(240, 6, 6);
  border-bottom: 0;
  border-left: 0;
  bottom: 0;
  top: 0.5em;
  height: auto;
  }

.tree li:last-child:before {
  height: 1em;
  bottom: auto;
  }

.tree > li:last-child:before { display: none; }

.tree_custom {
  display: block;
  background: #eee;
  padding: 1em;
  border-radius: 0.3em;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">


</head>
<body translate="no">
    <p><a href="#" id="tree-expand-all">Expand all</a> | <a href="#" id="tree-collapse-all">Collapse all</a></p>

<br /><br />
<div id="fontSizeWrapper">
<label for="fontSize">Font size</label>
<input type="range" value="1" id="fontSize" step="0.5" min="0.5" max="5" />
</div>
<ul class="tree">
<li>
<input type="checkbox"  id="c1" />
<label class="tree_label" for="c1">Level 0</label>
<ul>
<li>
<input type="checkbox"  id="c2" />
<label for="c2" class="tree_label">Level 1</label>
<ul>
<li><span class="tree_label">Level 2</span></li>
<li><span class="tree_label">Level 2</span></li>
</ul>
</li>
<li>
<input type="checkbox" id="c3" />
<label for="c3" class="tree_label">Looong level 1 <br />label text <br />with line-breaks</label>
<ul>
<li><span class="tree_label">Level 2</span></li>
<li>
<input type="checkbox" id="c4" />
<label for="c4" class="tree_label"><span class="tree_custom">Specified tree item view</span></label>
<ul>
<li><span class="tree_label">Level 3</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>
<input type="checkbox" id="c5" />
<label class="tree_label" for="c5">Level 0</label>
<ul>
<li>
<input type="checkbox" id="c6" />
<label for="c6" class="tree_label">Level 1</label>
<ul>
<li><span class="tree_label">Level 2</span></li>
</ul>
</li>
<li>
<input type="checkbox" id="c7" />
<label for="c7" class="tree_label">Level 1</label>
<ul>
<li><span class="tree_label">Level 2</span></li>
<li>
<input type="checkbox" id="c8" />
<label for="c8" class="tree_label">Level 2</label>
<ul>
<li><span class="tree_label">Level 3</span></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

    

</body>
</html>

text`**




Checkbox in tabulator

I am using tabulator and I want to add a column that has check-boxes. In the header it should have a checkbox which, on getting checked or unchecked should select all or deselect all the check-boxes in the column.

Also, I want to know how can I get each value of the checkbox selected by the User to push them in the array. Please Help.




mardi 28 mai 2019

Send multiple checkbox values include false

Is there any way to send multiple checkbox values including unchecked checkbox values. For example, if I have 4 checkboxes and user checks first and last checkboxes, I want to get the params something look like vehicle=> ["1", "0", "0", "1"]. Any help?

<input type="checkbox" name="vehicle[]">
<input type="checkbox" name="vehicle[]">
<input type="checkbox" name="vehicle[]">
<input type="checkbox" name="vehicle[]">




When I open the Excel it runs the macro and change the date saved

Am doing a macro in a check box (Form Control), the main idea is when I check the check box in the next cell it saves the date of the day I marked the checkbox. But instead if I save the check box with the mark it gets updated when I open the document. erasing the saved date and updating today's date.

I've tried 2 ifs and Errors GoTo Err and doesn't work

this is the code I have: If ActiveSheet.Shapes("Check Box 2").ControlFormat.Value = 1 Then

cells(6, 5).Value = Date

Else

Range("E6").ClearContents

End If

I need to put some code that stops the actualization. Or it tells the macro that when the check box is mark doesn't have to update the date.




MVC: Looking for a full tutorial to send/receive checkbox status to backend with AJAX

I am looking for a tutorial with a full example of how to send with AJAX the status of a single checkbox to backend (post) and load checkbox status from back end to front end (get) in java MVC.




CSS checkbox with out custom checkbox

How to change checkbox styles without custom checkboxenter image description here

Expecting will be like below

enter image description here




lundi 27 mai 2019

How do I make Vuetify checkbox accurately reflect it's value?

I am attempting to get the vuetify checkbox to accurately display the correct checked value. For example I am making a check all box with 3 states [all, some, none]. If the state is none the box should be unchecked. If the state is all then it should be checked and some means it is indeterminate. My problem is that when the input-value is calculated as false and the v-checkbox gets clicked the checkbox will display as checked even though the value being fed to the component says it should be unchecked. How do I force the checkbox to always be what the input-value says it should be?

https://codepen.io/anon/pen/QRxoqL?&editable=true&editors=101

<v-checkbox :input-value="val"></v-checkbox>
...
data(){
  return {
    val: false,
  }
},

This is a simpler version but it illustrates my issue. When I click the checkbox in an unchecked state, it should remain unchecked unless the "val" variable changes to true. This will allow me to use a method to determine what state the checkbox should be displaying as and actually have that displaying.




check checkbox on populated dropdown value selection via javascript

i got for the 6 Scenario what i want to do 6 checkboxes:

    <tr style="height: 21px;">
<td style="width: 25%; height: 21px;">COB</td>
<td style="width: 25%; height: 21px;"><input name="COB" type="checkbox" id="COB" value="1" <?php if($_GET['COB'] == '1'){  echo 'checked="checked"';}?>/>           </td>
<td style="width: 25%; height: 21px;">SMT</td>
<td style="width: 25%; height: 21px;">  <input name="SMT" id="SMT" type="checkbox" value="1" <?php if($_GET['SMT'] == '1'){  echo 'checked="checked"';}?>/> </td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;">BGA</td>
<td style="width: 25%; height: 21px;">  <input name="BGA" id="BGA" type="checkbox" value="1" <?php if($_GET['BGA'] == '1'){  echo 'checked="checked"';}?>/> </td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;">  TSOP Typ 1 </td>
<td style="width: 25%; height: 21px;"><input name="TSOP" id="TSOP" type="checkbox" value="1"<?php if($_GET['TSOP'] == '1'){  echo 'checked="checked"';}?> /></td>
</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"> TSOP Typ 2</td>
<td style="width: 25%; height: 21px;"><input name="TSOP" id="TSOP" type="checkbox" value="2"<?php if($_GET['TSOP'] == '2'){  echo 'checked="checked"';}?> />     </td>

</tr>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"></td>
<td style="width: 25%; height: 21px;"> LGA</td>
<td style="width: 25%; height: 21px;"><input name="LGA" id="LGA" type="checkbox" value="1"<?php if($_GET['LGA'] == '1'){  echo 'checked="checked"';}?> />    </td>
</tr>

And here the PHP Part how i populate the Dropdown.

<td style="width: 14.2857%; height: 21px;">  <select id="FlashID" name="FlashID" onchange="FlashFunction()" size="1" >

                    <option disabled selected value> </option>;                             
            <?php
            foreach($connection->query($flash) as $m)
            {
                        if($m['FlashID'] == $_GET['FlashID']){
                $isSelected = 'selected="selected"';
            }else{
                $isSelected = '';
            }
            echo "<option data-COB='".$m['COB']."' data-SMT='".$m['SMT']."' data-BGA='".$m['BGA']."' data-TSOP='".$m['TSOP']."' data-LGA='".$m['LGA']."' value='" . $m['FlashID'] . "'".$isSelected."  >" .$m['SAP'] ."</option>";

            }
            ?> 
            </td>

Here is the SQL Table for the poplated Dropdown

FlashID   SAP   COB   SMT   BGA   TSOP    LGA
1        102292  0     1     0     2       0
3        102293  0     1     0     2       0
4        102294  0     1     0     2       0
5        102296  0     1     0     0       1
6        102412  0     1     0     1       0
7        102413  0     1     0     1       0
8        102414  0     1     0     1       0
9        102651  0     1     0     2       0
10       102652  0     1     0     2       0
11       102664  0     1     0     2       0

This is my not working Javascript Part:

<script>
function FlashFunction(){
var index = document.getElementById("FlashID").selectedIndex;
var COB = document.getElementById("FlashID").options[index].getAttribute("data-COB");
var SMT = document.getElementById("FlashID").options[index].getAttribute("data-SMT");
var BGA = document.getElementById("FlashID").options[index].getAttribute("data-BGA");
var TSOP = document.getElementById("FlashID").options[index].getAttribute("data-TSOP");
var LGA = document.getElementById("FlashID").options[index].getAttribute("data-LGA");
document.getElementsByName("COB")[0].value = COB;
document.getElementsByName("SMT")[0].value = SMT;
document.getElementsByName("BGA")[0].value = BGA;
document.getElementsByName("TSOP")[0].value = TSOP;
document.getElementsByName("LGA")[0].value = LGA;
}
</script>

Notice the TSOP can be value 1 or 2.

for ex. You see already if I select FlashID 6. TSOP and SMT Checkbox should be checked.

But atm I have no idea, how I can handle this in why my Javascript is not working Can someone help?




Can you put a checkbox in a switch statement for onOptionsItemSelected?

I followed part of the last example here: How to Add a CheckBox in Toolbar with custom background - android to add a custom star as a checkbox in my toolbar.

However, I would like to put the checkbox inside the switch statement of onOptionsItemSelected, but any code inside a switch statement like R.id.star_favorite is not called. Is there a better way to call updateFavorite() and still be able to use my custom star checkbox? @Ramtin

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main,menu);
    checkBox = (CheckBox) menu.findItem(R.id.star_favorite).getActionView();
    checkBox.setButtonDrawable(R.drawable.favorite_checkbox);
    checkBox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Log.e("onClick", "favorite button has been clicked");
            currentQuoteIsFavorite = !currentQuoteIsFavorite;
            updateFavorite(currentQuoteIsFavorite);
        }
    });
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch(item.getItemId()) {
        case R.id.star_favorite:
            //already tried putting code like updateFavorite() inside here but it's not called
        case R.id.share_quote:
            Log.e("INSIDE SHARE", currentQuote);
            shareQuote();
            break;
        case R.id.menu:
            break;
    }
    return super.onOptionsItemSelected(item);
}




Accessing values from checkboxes list passes in a function

I have created a list of checkboxes. When i click on a checkbox the values of all the checkboxes pass through the function instead of the checked one.

def vendorData(self, recs, rowide):

    self.chkVendorValue = "vendor"+rowide
    self.refEntryText = "ref" + rowide
    self.titleEntryText = "title" + rowide
    self.isbnEntryText = "isbn" + rowide
    self.qtyEntryText = "qty" + rowide
    currpoinfo = str(recs[4]) + "_" + str(recs[1])
    self.arrSelect[self.arrMatrixHead[self.i]] = Checkbutton(self.InsideFrame, variable=self.chkVendorValue, onvalue=1,
                        offvalue=0, font=config.allLabels(), justify=LEFT, command = self.chkSelected(currpoinfo))

    self.arrSelect[self.arrMatrixHead[self.i]].pack()
    self.arrSelect[self.arrMatrixHead[self.i]].place(x=config.xrow, y=config.ycol, width=20, height=25)

#---------------------------Description Module------------------------------- def chkSelected(self, porefid): #print("chkvalue: ", self.chkVendorValue)

    print("porefid", porefid)
    if porefid != "0" and porefid != "":
        poinfo =  porefid.split("_",2)

chkvalue: vendorrow0 porefid 2_9780306407062 chkvalue: vendorrow1 porefid 2_9781552096246 chkvalue: vendorrow2 porefid 1_9781849733816 I wanted only one pair of values instead of 3.




Checkbox display content without using JS in Html & CSS

I'm setting up checkbox in a side navigation fashion in my html pages, I want the check box to display content upon selection. Example: Choose checkbox 1,2 display content only of that, No checkbox selected display all content.. How can i do this without Jquery/javascript. I want my webpage to maintain same functionality even if Javascript in browser is disabled. Can i do this by including w3.css as these styles are responsive without involving bootstrap




Set value on model when checkbox changes

I have a page which contains usnernames and checkboxes for every user. it looks like a matrix.

Now when changing one of the checkboxes, I want to change a value on the user, so I know which user is changed. This way I can check which users I need to update in the database.

My page-code looks as follows:

@for(var i = 0; i < Model.EmployeeList.Count; i++)
{
    <input type="hidden" asp-for="EmployeeList[i].Id"/>
    <tr>
    <th scope="row">@Model.EmployeeList[i].Name @Model.EmployeeList[i].Surname</th>
<th scope="row">@Model.EmployeeList[i].Location</th>
@for (var j = 0; j < Model.EmployeeList[i].SelectedSkillList.Count; j++)
{
<td>

    @*<div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" id="customCheck1">
        <label class="custom-control-label" for="customCheck1">Check</label>
    </div>*@
        <label class="label">
            <input asp-for="EmployeeList[i].SelectedSkillList[j].IsSelected" type="checkbox" class="label__checkbox"/>
            <span class="label__text">
                <span class="label__check">
                    <i class="fa fa-check icon"></i>
                </span>
            </span>
        </label>

    @*<input asp-for="EmployeeList[i].SelectedSkillList[j].IsSelected" type="checkbox" />*@
    @*If this is not included, prefix becomes null*@
    @Html.HiddenFor(x => Model.EmployeeList[i].SelectedSkillList[j].Prefix)
    @Html.HiddenFor(x => Model.EmployeeList[i].IsChanged)
</td>
}
</tr>
}




selenium checkbox click not working in python

https://agent.loadbook.in/#/login When I go to the signup form, the form has a checkbox as I agree with the condition. It's an Input tag checkbox. when I select the tag by id and when I perform click or send_key of submitting its showing checkbox not clickable.

below all Method are not work driver.find_element_by_xpath('//div[@class="switch__container"]//input').click()

driver.find_element_by_xpath('//div[@class="switch__container"]//input').send_keys(Keys.ENTER)

driver.find_element_by_xpath('//div[@class="switch__container"]//input').submit()

driver.find_element_by_xpath('//div[@class="switch__container"]//input').send_keys("after")

driver.find_element_by_xpath('//div[@class="switch__container"]//label').click()

driver = webdriver.Chrome(options=chrome_options) driver.get("https://agent.loadbook.in/#/login")

driver.find_element_by_partial_link_text("Create an account").click()

try:

driver.find_element_by_xpath('//div[@class="switch__container"]//input').click()
# driver.find_element("name","username").send_keys("test")
# driver.find_element("name","email").send_keys("test@test.com")
# driver.find_element("name","phone").send_keys("99999999")
# driver.find_element("name","password").send_keys("12345")

except NoSuchElementException as exception: print("not found")

selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable




By clicking one checkbox other checkbox should be disable

I've 2 columns with checkboxes when one column is checked all respective are checked likewise in 2nd column but the problem is here, client wants when One column of checkbox is checked then 2nd column will be disable or throw alert message to check only one column at a time?

function SelectAll1(headerchk, gridId) {

        var gvcheck = document.getElementById(gridId);
        var i, j;
        if (headerchk.checked) {
            for (i = 0; i < gvcheck.rows.length - 1; i++) {
                var inputs = gvcheck.rows[i].getElementsByTagName('input');
               for (j = 1; j < inputs.length; j++) {
                 if (inputs[j].type == "checkbox") {
                        inputs[j].checked = true;
                    }
                }
            }
        }
        else {
            for (i = 0; i < gvcheck.rows.length - 1; i++) {
                var inputs = gvcheck.rows[i].getElementsByTagName('input');
                 for (j = 1; j < inputs.length; j++) {
                   if (inputs[j].type == "checkbox") {
                        inputs[j].checked = false;
                    }
                }
            }
        }
    }

You can ch




Powershell: CheckBox.Add_CheckStateChanged

I've started with powershell forms and this is my first attempt. I'd like to add more checkboxes and I've a problem with "CheckStateChanged". How can I shorten the code with my checkboxes using foreach x in y?

CheckBox1.Add_CheckStateChanged({ if (CheckBox1.Checked){foreach CheckBox in $_.Enabled = $false} else {$CheckBox2.Enabled = true}

My first attempt:

$CheckBox1.Add_CheckStateChanged({
if ($CheckBox1.Checked){$CheckBox2.Enabled = $false} else {$CheckBox2.Enabled = $true}
if ($CheckBox1.Checked){$CheckBox3.Enabled = $false} else {$CheckBox3.Enabled = $true}
if ($CheckBox1.Checked){$CheckBox4.Enabled = $false} else {$CheckBox4.Enabled = $true}
})

$CheckBox2.Add_CheckStateChanged({
if ($CheckBox2.Checked){$CheckBox1.Enabled = $false} else {$CheckBox1.Enabled = $true}
if ($CheckBox2.Checked){$CheckBox3.Enabled = $false} else {$CheckBox3.Enabled = $true}
if ($CheckBox2.Checked){$CheckBox4.Enabled = $false} else {$CheckBox4.Enabled = $true}
})

$CheckBox3.Add_CheckStateChanged({
if ($CheckBox3.Checked){$CheckBox1.Enabled = $false} else {$CheckBox1.Enabled = $true}
if ($CheckBox3.Checked){$CheckBox2.Enabled = $false} else {$CheckBox2.Enabled = $true}
if ($CheckBox3.Checked){$CheckBox4.Enabled = $false} else {$CheckBox4.Enabled = $true}
})

$CheckBox4.Add_CheckStateChanged({
if ($CheckBox4.Checked){$CheckBox1.Enabled = $false} else {$CheckBox1.Enabled = $true}
if ($CheckBox4.Checked){$CheckBox2.Enabled = $false} else {$CheckBox2.Enabled = $true}
if ($CheckBox4.Checked){$CheckBox3.Enabled = $false} else {$CheckBox3.Enabled = $true}
})




checkbox click function is not working angular 4

i have this data coming from another component on the basis of active tag when row is clicked i am pushing Id to ngModel of checkbox input field. row click is working fine and checkbox is adding/removing data but now when i click on checkbox itself it doesn't do anything like checkbox click function is not working how can i solve that?

html component

<ngb-panel [disabled]="true" *ngFor="let testPanel of otherTests; let i = index;" id="" [title]="testPanel.Name">
  <ng-template ngbPanelTitle>
    <div class="action-items">
      <label class="custom-control custom-checkbox">
          <input
            type="checkbox"
            class="custom-control-input"
            [name]="testPanel.Id + '-' + testPanel.Moniker"
            [ngModel]="panelIds.indexOf(testPanel.Id) > -1"
            (ngModelChange)="onPanelCheckboxUpdate($event, testPanel)"
            [id]="testPanel.Id + '-' + testPanel.Moniker">
          <span class="custom-control-indicator"></span>
      </label>
    </div>
  </ng-template>
</ngb-panel>

ts component

getting Id from service and push it on basis of row click

this.testOrderService.refreshRequestsObservable().subscribe(
  data => {

    this.panelActive = data.active;
    let testFilteredArray = lodash.filter(this.otherTests, item => item.Id === data.id);

    if (this.panelActive) {
      // is checked
      this.panelIds.push(data.id);
      if(testFilteredArray.length > 0){
        this.selectedPanels.push(testFilteredArray[0]);
      }
    }
    else {
      //is false
      this.panelIds = this.panelIds.filter(obj => obj !== data.id);
      this.selectedPanels = this.selectedPanels.filter(obj => obj.Id !== data.id);
    }

    // this.panelIds = lodash.uniq(this.panelIds);
    this.selectedPanels = lodash.uniqBy(this.selectedPanels, "Id");

    this.updateSession();

  }
)

checkbox function

onPanelCheckboxUpdate($event: boolean, panel: TestOrderPanel) {
let testPanelIds = panel.Tests.map(test => test.Id);
// Wipe any duplicates
this.panelIds = this.panelIds.filter(
  panelId => panel.Id !== panelId && testPanelIds.indexOf(panelId) === -1
);
this.selectedPanels = this.selectedPanels.filter(
  selectedPanel =>
    panel.Id !== selectedPanel.Id &&
    testPanelIds.indexOf(selectedPanel.Id) === -1
);

if ($event) {
  this.panelIds.push(panel.Id);
  this.selectedPanels.push(panel);
 }
 this.updateSession();
 }

this checkbox function is not working and wont let me change the value of checkbox any help? thanks




dimanche 26 mai 2019

Datatables Checkboxes select multiple on matching ids

I have a server-side datatable setup with the checkboxes plugin. Each checkbox has the data of a product_id.

var table = $('#display_users').DataTable( {
        "processing": true,
        "serverSide": true,
        'ajax': '',
        'columns' : [
            {"data" : "product_id"},
            {"data" : "product_id"},
            {"data" : "first_name"},
            {"data" : "last_name"},
            {"data" : "email"},
            {"data" : "company"},
            {"data" : "department"},
            {"data" : "created_at"}
        ],
        'columnDefs': [
            {
                'targets': 0,
                'checkboxes': {
                    'selectRow': true
                },

I would like to be able to, when a checkbox is selected, select all the checkboxes with the same product_id. This is only necessary for the records on the currently selected page. It seems this should be possible with the checkboxes select api, however I haven't been successful so far




samedi 25 mai 2019

check checkbox on populated dropdown value selection [SQL-SERVER]

got for this example 8 checkboxes:

 <table style="border-collapse: collapse; width: 100%;" border="1">
    <tbody>


    <tr style="height: 21px;">
    <td style="width: 25%; height: 21px;"><strong>Technologie</strong></td>
    <td style="width: 25%; height: 21px;"></td>
    <td style="width: 25%; height: 21px;"></td>
    <td style="width: 25%; height: 21px;"></td>
    </tr>
    <tr style="height: 21px;">
    <td style="width: 25%; height: 21px;">Tec1</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec1]" type="checkbox" value="1" /> </td>
    <td style="width: 25%; height: 21px;">Tec2</td>
    <td style="width: 25%; height: 21px;"><input name="Technologie[Tec2]" type="checkbox" value="1" /></td>
    </tr>
    <tr style="height: 21px;">
    <td style="width: 25%; height: 21px;">Tec3</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec3]" type="checkbox" value="1" /> </td>
    <td style="width: 25%; height: 21px;"Tec4</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec4]" type="checkbox" value="1" /> </td>
    </tr>
    <tr style="height: 21px;">
    <td style="width: 25%; height: 21px;">Tec5</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec5]" type="checkbox" value="1" /> </td>
    <td style="width: 25%; height: 21px;">Tec6</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec6]" type="checkbox" value="1" /> </td>
    </tr>
    <tr style="height: 21px;">
    <td style="width: 25%; height: 21px;"></td>
    <td style="width: 25%; height: 21px;">Tec7</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec7]" type="checkbox" value="1" /> </td>
   <td style="width: 25%; height: 21px;">Tec8</td>
    <td style="width: 25%; height: 21px;">  <input name="Technologie[Tec8]" type="checkbox" value="2" /> </td>

    </tr>
    </tbody>
    </table>

Here is the SQL Table for the poplated Dropdown:

+--------+------+------+------+------+------+------+------+------+------+
| Tec_ID | Tec1 | Tec2 | Tec3 | Tec4 | Tec5 | Tec6 | Tec7 | Tec8 |RanNr |
+--------+------+------+------+------+------+------+------+------+------+
|      1 |    1 |    0 |    0 |    0 |    1 |    0 |    0 |    0 | 1353 |
|      2 |    1 |    0 |    0 |    0 |    0 |    1 |    0 |    0 | 0000 |
|      3 |    1 |    0 |    0 |    0 |    0 |    0 |    1 |    1 | 1353 |
|      4 |    1 |    1 |    1 |    0 |    1 |    0 |    0 |    0 | 1123 |
|      5 |    1 |    1 |    1 |    0 |    0 |    1 |    0 |    2 | 1353 |
|      6 |    1 |    1 |    1 |    0 |    0 |    0 |    1 |    2 | 1353 |
|      7 |    0 |    0 |    0 |    1 |    0 |    0 |    0 |    1 | 1993 |
|      8 |    0 |    1 |    1 |    0 |    1 |    0 |    0 |    0 | 1123 |
|      9 |    0 |    1 |    1 |    0 |    0 |    1 |    0 |    0 | 1353 |
|     10 |    0 |    0 |    0 |    0 |    0 |    0 |    0 |    2 | 1366 |
+--------+------+------+------+------+------+------+------+------+------+

And here the PHP Part how i populate the Dropdown.

<select id="Tec_ID" name="Tec_ID" size="1" >    
                    <option disabled selected value> </option>;

            <?php
            foreach($connection->query($tec) as $m)
            {
                        if($m['Tec_ID'] == $_GET['Tec_ID']){
                $isSelected = 'selected="selected"';
            }else{
                $isSelected = '';
            }
            echo "<option value='" . $m['Tec_ID'] . "'".$isSelected."  >" .$m['RanNr'] ."</option>";
            }
            ?> 

Notice the last Tec8 can be value 1 or 2.

for ex. You see already if I select Tec_ID 1. Tec1 and Tec5 Checkbox should be checked.

But atm I have no idea, how I can handle this in with Javascript/PHP/MSQLCode? Can someone help?




how to remove item of an array when deselect the checkbox angular 4

hey i have this array of objects. in each object there is another array.

panels = [{
  Id: "26cfdb68-ef69-4df0-b4dc-5b9c6501b0dd",
  Name: "Celiac test",
  Tests: [{
      Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
      Name: "test 1 (DGP) IgG"
    },
    {
      Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
      Name: "test 2 (DGP) IgG"
    },
    {
      Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
      Name: "test 3 (DGP) IgG"
    }
  ]
}],

i have mapped it on bootstrap accordion with checkboxes first there is checkbox of main object then checkboxes of array within object.

what i want is when i click on main Panel checkbox it should select the Tests checkboxes and save the panel object in object variable say selectedPanel and when i deselect the main Panel it should deselect all the Tests checkboxes too. that i can do but main thing is when i deselect one of Tests checkboxes it should be removed from selectedPanel and length also. can anyone help me in this regard?

i have created stackblitz too

Stackblitz




vendredi 24 mai 2019

Select one only one row in ant-design table component

i'm having a problem here. It is mandatory for my project to user ant design. The link is here: https://ant.design/components/table The component i must use is a table component. When i click on a row i must dispatch an action. The problem i'm facing is that i must check only one row. As a result when i click on a row the checkbox in the previous row should be deselected.

I've tried to add some logic as you can see here:

class EvaluationDataTable extends React.Component {
  state = {
    selectedRowKeys: [], // Check here to configure the default column
  };

  onSelectChange = selectedRowKeys => {
    if (selectedRowKeys.length > 1) {
      const lastSelectedRowIndex = [...selectedRowKeys].pop();
      this.setState({ selectedRowKeys: lastSelectedRowIndex });
    }
    this.setState({ selectedRowKeys });
    console.log('selectedRowKeys changed: ', selectedRowKeys);
  };

  render() {
    const { selectedRowKeys } = this.state;
    const rowSelection = {
      selectedRowKeys,
      onChange: this.onSelectChange,
    };
    return (
      <React.Fragment>
        <div style= />
        <Table
          rowSelection={rowSelection}
          columns={columnEvaluation}
          dataSource={result}
        />
      </React.Fragment>
    );
  }
}```

But even if the selectedRow has the last checked row the no checkbox is checked. Any ideas?




Antd: I'm trying to change the default styling of Antd's checkboxes using styled components to make the checkbox larger and change the color to black

I have an Antd checkbox that I'm trying to make larger, alter the thickness of the box itself and change the color to black but every style I apply creates a second square that sits over the checkbox and doesn't change the checkbox itself. Does anyone have any ideas on how to do this?




Error : I want to get a value from checked checkbox datatable Ajax and jequery

I want to get value of " IG " when it checked and post to ajax

  "select": {
     "style": "multi"
  },

"processing" : true,
"serverSide" : true,
"order" : [],

"ajax" : {
 url:"accfiltrage.php",
 type:"POST",

}

$('#customer_dataa tbody').on( 'click', 'tr', function () {
    $(this).toggleClass('selected');
} );
$('#button').click( function () {
  swal( table.rows('checkboxes.selected').data().length +' Commande selectioner login to continue ' ).then(

  function() {
        window.location.href = "login.php";
    })



} );

Please help image for my code

1:

https://i.stack.imgur.com/Cuf2k.png




Issue with getting value of checkboxes tkinter

I'm trying to get the value of checkboxes in tkinter so I can have the data from those checkboxes exported into a excel spreadsheet

I've tried having the checkboxes generate iteratively (as they are presently) and making them manually, but no matter what I do, can't get them to give me their values (whether they are checked or not) and it's really stressing me out.

def check():
    for movie in movies():
        print(button.get())

Button(moviewindow,text="Check",command=check).pack(anchor=S)
for movie in movies():
            var1 = IntVar() 
            button = Checkbutton(moviewindow,
                        bg=moviewindow_bg,
                        font=("Times",23),
                        onvalue=1,
                        offvalue=0,
                        text=movie.replace("<strong>","").replace("</strong>",""),
                        variable=var1).pack(anchor=W)

I expect the code to print either 1 or 0, but I cant get the checkboxes to return their values.




Please i have a problem with The function, whenever i click the checkbox it dosen't disable for me to type in something

How can i Make the text box disabled when i click the checkbox?

var1 =IntVar()
var1.set(0)
E_Rice=StringVar()
E_Rice.set("0")

def chkR():
    if  (var1.get()==1):
        txtRice.configure(state = NORMAL)
        txtRice.focus()
        txtRice.delete('0',END)
        E_Rice.set("")
    elif(var1.get()==0):
        txtRice.configure(state = DISABLED)
        E_Rice.set("0")

Rice=Checkbutton(root,text=" Rice",variable=var1, onvalue=1,       offvalue=0,font=('arial',16,'bold'),
                bg='pale green',command=chkR).grid(row=0,sticky=W)

txtRice = Entry(root,font=('arial',10,'bold'),bd=6,width=6, justify='right',state = DISABLED,textvariable=E_Rice).grid(row=0,column=1)




All Checkboxes prop checked but I only want ONE checkbox to be triggered

I have list of items that can be "add to favorite", in this case I use checkbox, so user can check the checkbox to add to favorite, and vice versa, uncheck the checkbox to remove from favorite.

The flow suppose to be like this:

  1. When the checkbox is unchecked, and user click on it, it will be checked

  2. When the checkbox is checked, and user click on it, it will trigger a modal which ask them to confirm if they really want to remove the item from favorite. In the pop up modal, there is a confirm button, and when user click on it, it will uncheck the checkbox and close the pop up modal.

Below are the html element

    <div class="star_wrap">
      <input type="checkbox" /><label onclick="confirmLabelRemove(this)"><label>
    </div>
    i put the click event in label to trigger the input before it to be checked or unchecked

Below are the code to generate the unique ID for each checkbox

    var listItems = $(".star_wrap"); // the container of each checkbox
    listItems.each(function (idx) {
    $(this).find('input').attr('id', 'chkbox' + idx);
    //$(this).find('label').attr('for', 'chkbox' + idx); I don't want this 
    feature because If I click on the label it will prop check the 
    checkbox before the pop up modal show up.
});

Below are the code to trigger prop check event

    function confirmLabelRemove(obj) {
    var thisLabelInput = $(obj).prev(); // find the input before the label

    if ($(thisLabelInput).is(':checked')) {
    overlayConfirmShow(); // transparent layer to prevent back content clickable
    $('.confirmation_box').addClass('show'); // show the pop up modal

    $('#confirmBoxConfirm').on('click', function () {
        $(obj).prev().prop('checked', false);
        $(obj).closest('.grid-item').addClass('unfav');
        overlayConfirmHide();
        $('.confirmation_box').removeClass('show');
     });
    } else {
      $(obj).closest('.grid-item').removeClass('unfav');
      $(obj).prev().prop('checked', true);
     }
    }

If there is only 1 checkbox, it works perfectly fine. But when they are a list of checkboxes, Unchecking and checking 1 of the checkbox will trigger previously checked or unchecked checkboxes. Please advice, thanks.




jeudi 23 mai 2019

How can I add a CheckBox to the GridPane after the scene has already been loaded/shown?

I'm writing a program that sorts a list of Json objects and then formats/prints the data in each Json Object. I've created a GUI that allows the user to select which JSON Strings from the Json Object they would like to include in the final print.

To do this, I have a button for the user to press that loads a HashMap of String/Checkbox Pairs, where the string is the KEY_NAME of the respective JSON String. What I want to do is, after the scene has been loaded and the GUI shown, add the CheckBox's from the map to an existing GridPane in the scene.

I've tried the version below, and also tried it without re-adding the gpane to the AnchorPane. So far nothing has caused the scene to refresh. How can I accomplish this?

public void addCheckboxes(GridPane gpane, AnchorPane pane, Map<String, CheckBox> map){
    Iterator it = map.entrySet().iterator();
    int row = 1, col = 0;
    while(it.hasNext()){
        Map.Entry pair = (Map.Entry) it.next();
        gpane.add((CheckBox) pair.getValue(), col, row);

        pane.getChildren().add(gpane);

        row++;
    }
}




Disable\Enable multiple checkboxes in Kendo UI TreeList

I tried these solutions for disable\enable multiple checkboxes in Kendo UI TreeList when header checkbox is clicked:

1.prop('disabled',true) \ prop('disabled',false)

2.attr('disabled','disabled') \ removeAttr('disabled');

3.$(...)[0].disabled=true \ $(...)[0].disabled=false

But all of them has the same problem which affects just the last item in the TreeList !!!

I really confused and don't know what is going wrong, is it possible to be resolved?




Vuetify checkbox true-value seems to be bugged?

I have been attempting to use the true-value and false-value props on the v-checkbox element.

I have attempted on this codepen and it would not work: https://codepen.io/anon/pen/pmaZpd?editors=1010

<v-checkbox v-model="devText1" true-value="Yes" false-value="No"/>

However when I looked in the vuetify definition of the component the properties do in-fact exist though they are not documented.

I changed the falseValue and trueValue property definition in node_modules/vuetify/src/mixins/selectable.js from null to {} and back it started working.

Is this an issue with the current version of vuetify?




ionic muiltiselect checkbox not working in my ionic application

I am trying to deselect all the checkboxes with the "deselect all" checkbox, but the method is not being called for the first time. It's working fine on the second click.

I expect all the checkboxes to be deselected on every click.

ionic mobile application

  <ion-col class="reason-top">
    <div class="">
      <ion-label ><b>  LblReason</b></ion-label>
      <ion-item class="form-line-active shift" no-lines>
      <ion-label>   LblMjReason </ion-label>
      <ion-select #myselect multiple="true" 
            class="selector" (click)="openSelect(myselect)" 
          [(ngModel)]="selectedReason">
        <!-- <ion-option value="Planned"> 
          LblPlanned</ion-option>
        <ion-option value="Electrical"> 
              LblElectrical</ion-option>
        <ion-option value="Mechanical"> 
           LblMechanical</ion-option>
        <ion-option value="Operator"> 
          LblOperator</ion-option>
        <ion-option value="Utility">{ 
        LblUtility</ion-option>
        <ion-option value="Roll Change"> 
              LblRollChange</ion-option>
        <ion-option value="Level2"> 
          LblLevel2</ion-option>
        <ion-option value="Level3"> 
           LblLevel3</ion-option>
        <ion-option value="Other"> 
     LblOther</ion-option> -->


         <ion-option (ionSelect)="allClicked(myselect)"  >All</ion-option>
         <ion-option *ngFor="let n of names" value=""></ion-option>

        <!-- <ion-option value="J" 
              [selected]="true">All</ion-option> -->
        </ion-select>
      </ion-item>
    </div>
  </ion-col>


  </ion-row>
  </table>
</ion-grid> 




Checkbox checked works only once

Message sending form, the customer has to select at least one of the alternatives (mail, SMS).

Send button would be disabled if none is selected and activate if one or both selected

$(document).ready(function() {
  $('.form-check-input').change(function() {
    $(this).each(function() {
      if (!$(this).is(':checked')) {
        $("#send").attr("disabled", "disabled");
      }
    });
  });
});
<div>
  <div class="row">
    <div class="col-md-12 form-check">
      <div>
        <input class="form-check-input" type="checkbox" value="" id="Epost" checked>
        <label class="form-check-label" for="E-post">E-post</label>
      </div>
      <div>
        <input class="form-check-input" type="checkbox" value="" id="SMS">
        <label class="form-check-label" for="SMS">SMS</label>
      </div>
      <br>
      <button id='send'>Send</button>
    </div>
  </div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>



How to enable required text field on submit only in an Angular 5 app?

I have the following template with textbox:

<input type="checkbox" id="s_i" name="s_i" (change)="clickObj($event, myObjs[i])" [(ngModel)]="myObjs[i].isSelected">
<input type="text" [ngModelOptions]="{ updateOn: 'blur' }" [required]="myObjs[i].isSelected"
 id="f_p_" name="p_p_" [(ngModel)]="myObjs[i]">

When clicking on the checkbox the textfield become red automatically and not let the user a chance to enter value. I need to mark error only when clicking submit. Any idea what should I change/add in order fix this ? Thanks.




How to implement multiple checkbox using react hook

I want to implement multiple checkbox on my html page using react-hook.

I tried implementing using this URL: https://medium.com/@Zh0uzi/my-concerns-with-react-hooks-6afda0acc672 . In provided link it is done using class component and working perfectly but whenever i am using react hook setCheckedItems to update checkbox checked status its not re-rendering view. Very first time view is rendering and console.log() is printing from Checkbox component. After clicking on checkbox function handleChange gets called and checkedItems updates the value but view is not rendering again (no console.log() printing). And {checkedItems.get("check-box-1")} is also not printing any value.

Below is my sample code.

CheckboxExample :

import React, { useState } from 'react';
import Checkbox from '../helper/Checkbox';

const CheckboxExample = () => {
    const [checkedItems, setCheckedItems] = useState(new Map());

    const handleChange = (event) => {
        setCheckedItems(checkedItems => checkedItems.set(event.target.name, event.target.checked));
        console.log("checkedItems: ", checkedItems);
    }

    const checkboxes = [
        {
            name: 'check-box-1',
            key: 'checkBox1',
            label: 'Check Box 1',
        },
        {
            name: 'check-box-2',
            key: 'checkBox2',
            label: 'Check Box 2',
        }
    ];


    return (
        <div>
            <lable>Checked item name : {checkedItems.get("check-box-1")} </lable> <br/>
            {
                checkboxes.map(item => (
                    <label key={item.key}>
                        {item.name}
                        <Checkbox name={item.name} checked={checkedItems.get(item.name)} onChange={handleChange} />
                    </label>
                ))
            }
        </div>
    );
}
export default Example;

Checkbox:

import React from 'react';

const Checkbox = ({ type = 'checkbox', name, checked = false, onChange }) => {
    console.log("Checkbox: ", name, checked);

  return (<input type={type} name={name} checked={checked} onChange={onChange} /> )
}
export default Checkbox;




Default checkbox is circle - how to transform it to square?

I have problem with my checkbox. Everytime I get circle checkbox, but i want the default one - square. I am creating my checkbox in .jsp like this:

<input type='checkbox' name='foo' value='bar' checked='' id="inlineCheckbox2" style="transform: scale(1.5);">

And I got this:

enter image description here




mercredi 22 mai 2019

How can I perform a certain action if and only if a specific CheckBox is checked, from a separate class, at runtime?

I'm writing a program that takes a JsonFile as input and parses/sorts it before printing the result. The result is an array of JsonObjects, each JsonObject with its list of KEY_NAME's and their strings.

I also have a GUI from javafx, and a GridPane of CheckBox's, with an individual CheckBox for each KEY_NAME. What I want to do is, at runtime if a CheckBox is checked, print the JsonString corresponding to that checkbox. Essentially filtering the output of the sorted file. I want to do this from a separate class aside from the main class that put's together the javafx GUI.

Do I need to create several listener functions? Or is there a simpler way? I have 50 or so checboxes so this would be a lot of lines.

On a side note, is there a way to dynamically create these at runtime, naming them after their respective JsonString, rather than typing each CheckBox?




Checkbox selection based on name is prompting other checkbox options

I am attempting to set the value of newStatus or usedStatus if any of the options for either is selected, but for only the ones that are selected.

As of now, if you select "New mowers" and then click on one of its options, you will see in the console that New Selection1 and Used Selection is displayed in the console. For this example and the functionality, only New Selection1 should be showing.

The following if statements are controlling it:

if ("input:checkbox[name=newMowerOption]:checked") {
    newStatus = '1';
    console.log('New Selection' + newStatus);
}
if ("input:checkbox[name=usedMowerOption]:checked") {
    usedStatus = '1';
    console.log('Used Selection' + usedStatus);
}

You can see that I am checking for the specific checkboxes based on the name, so I am unsure why if you select a new mower option that the used is also selected.

Anyone have an idea?

var newStatus = ''; //Telling whether new is selected
        var usedStatus = ''; //Telling whether used is selected
        var newSelPush = '';
        var usedSelPush = '';
                
        $('.equipmentOptionCont').change(function() {

                var newSel = [];
                var usedSel = [];

                //Get new mower options
                $("input:checkbox[name=newMowerOption]:checked").each(function(){
                        newSel.push($(this).val());
                        newSelPush = newSel.join(', ');
                });
                //Get used mower options
                $("input:checkbox[name=usedMowerOption]:checked").each(function(){
                        usedSel.push($(this).val());
                        usedSelPush = usedSel.join(', ');
                });
                //Find out if new/used mower option is selected and then create variable showing 1 if true
                if ("input:checkbox[name=newMowerOption]:checked") {
                        newStatus = '1';
                        console.log('New Selection' + newStatus);
                }
                if ("input:checkbox[name=usedMowerOption]:checked") {
                        usedStatus = '1';
                        console.log('Used Selection' + usedStatus);
                }
                $('#newSel').html(newSelPush);
                $('#usedSel').html(usedSelPush);
        });

        $('#newAllOptions').click(function() {
                $('input[name=newMowerOption').toggle().prop('checked', true);
        });
        $('#usedAllOptions').click(function() {
                $('input[name=usedMowerOption').toggle().prop('checked', true);
        });
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label>New Mowers</label>
                <input type="radio" name="notifymethod" id="newMowerSelect" class="equipmentMainSel">
                <label>Used Mowers</label>
                <input type="radio" name="notifymethod" id="usedMowerSelect" class="equipmentMainSel">
                <div id="newMowerOptions" class="equipmentOptionCont">
      <p>New Mower Options</p>
                        <label>Ferris</label>
                        <input type="checkbox" name="newMowerOption" value="Ferris">
                        <label>Wright</label>
                        <input type="checkbox" name="newMowerOption" value="Wright">
                </div>
                <div id="usedMowerOptions" class="equipmentOptionCont">
      <p>Used Mower Options</p>
                        <label>Toro</label>
                        <input type="checkbox" name="usedMowerOption" value="Toro">
                        <label>John Deere</label>
                        <input type="checkbox" name="usedMowerOption" value="John Deere">
                </div>



setChecked and setSelected in CheckBox not working

I have an Activity which has 5 fragments in pager. I used

 viewPager.setOffscreenPageLimit(fragmentList.size());

to be able to creat all fragment in one time I also have a listener wich will pass parameter(object) to all fragment once I have a newIntent.

in one of my fragment I have CheckBox wich should be selcted according to the parameter from activity. and other views wich I were able to change the value of thier texts and background. just this check box I have set it on But when I see it, I have see it is off , all other events works well.

here is the activity

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTheme(R.style.AppTheme_PopupOverlay);
    setContentView(R.layout.activity_configurations);

    ViewPager viewPager = findViewById(R.id.container);
    TabLayout tabLayout = findViewById(R.id.tabs);

    setNdef(getIntent().getExtras());
    String type = getNdef().getString("id");

    List<Fragment> fragmentList = createFragments(type);
    SectionsPagerAdapter pagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager(), fragmentList);
    viewPager.setAdapter(pagerAdapter);

    fillTableLayout(tabLayout, type);

    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
    tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(viewPager));
    tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
    viewPager.setOffscreenPageLimit(fragmentList.size());
    readNfcDialog = createReadDialog();
    writeNfcDialog = createWriteDialog();
    readNfcDialog.show();
    setForeground();
}

 @Override
protected void onNewIntent(Intent intent) {

    super.onNewIntent(intent);


    ClassNfcTag wepTag = new ClassNfcTag(intent);
    String type = wepTag.defineClassTag();
    OmsRepeaterTag omsRepeaterTag = new OmsRepeaterTag(intent);
    byteMap = omsRepeaterTag.readTag();
   if (byteMap != null) {
   setTagOmsConfiguration(OmsConfiguration.fromByteArray(byteMap));
   for (OmsListener listener : onReceiveOmsList) {
        listener.gotOms(getInTagOmsConfiguration());
       }
   }
}

and here is one of the fragments

    @Override
public void gotOms(OmsConfiguration configuration) {
    setConfiguration(configuration);
    if (isAdded()) {
    boolean status = getConfiguration().getDeleteRsl();
    delete.setChecked(status);
    delete.setSelected(status);

    }
}

as a solution I have tried to use Switch instead of CheckBox and it worked well.

and I also tried to set the pager to start from exactly the fragment which has the CheckBox and it also work.

viewPager.setCurrentItem(checkBoxFragmentPosition);

I also tried to debugg the code and It shows me that the checBox is checked and when I tried to change it to checked by touching it (progamitly it is checked , in Ui I see it unchecked) it change itself from unchecked to unchecked .and then with the next touch changed to checked.

I will be really happy to see your solutions.