mercredi 31 juillet 2019

Tree view with check-box react-native

Want to achieve treeview with check boxes. tree view is available with

zaguiini/react-native-final-tree-view

but no checkboxes .need with selection of multiple items Similar to below

enter image description here

Thanks in advance




Accessing remote hierarchical treeview dataitem

I need help. The coding below run perfectly with local data but when implement it with remote data the function for tv.dataItems() show nothing. How can i access the data from the hierarchical data for my treeview? i want to get all the id for the nodes of the treeview.

JavaScript for accessing the dataItem

    var values = ["LA1","LA6","LA12"]; 


    var setTreeViewValues = function(values) {
    var tv = $("#AccountingTree").data("kendoTreeView");

    document.write(JSON.stringify(tv));

    tv.dataItems().forEach(function(dataItem) {   
    alert("test");
       if (dataItem.hasChildren) {
       var childItems = dataItem.children.data();
       //document.write(JSON.stringify(childItems[0].items[0].programID)); 
    }

   // document.write(JSON.stringify(dataItem.items)); 
      if (values.indexOf(childItems[0].items[0].programID) > -1) { 

        dataItem.set("checked", true);
      }
    });


  };

  setTreeViewValues(values);

The output is here

Is there anyone know what the problem happen here?




wp query on checkboxes value

I am creating a search system with data from front-end checkboxes and wp query on a custom post-type. But the query does not work, "0 item found".

I created a search form where users can search for an area according to several criteria: less than 50 m² from 50 to 200 m² from 200 to 1000m² greater than 1000 m² the search criteria values come from front-end checkboxes. And I have a custom post-type called "Houses" on the back end. I made a query with wp query but it does not work, it displays 0 result while there are posts that meet the search criteria.

$ args = array (
    ‘post_type’ => ‘Houses’,
    ‘posts_per_page’ => -1,
    ‘meta_query’ => array (
    ‘relation’ => ‘OR’,
     array (
    ‘key’ => ‘wpcf-area’,
    ‘value’ => 50,
    ‘type’ => ‘numeric’,
    ‘compare’ => ‘<‘
    ),
    array (
    ‘key’ => ‘wpcf-area’,
    ‘value’ => array (50, 200),
    ‘type’ => ‘numeric’,
    ‘compare’ => ‘BETWEEN’
    ),
    array (
    ‘key’ => ‘wpcf-area’,
    ‘value’ => array (200, 1000),
    ‘type’ => ‘numeric’,
    ‘compare’ => ‘BETWEEN’
     ),
    array (
    ‘key’ => ‘wpcf-area,
    ‘value’ => 1000,
    ‘type’ => ‘numeric’,
    ‘compare’ => ‘>’
    )
  )
);
$ query = new WP_Query ($ args);

I'm getting "0 result" while there are posts that meet the search criteria. Thank you




Make a checkbox checked if its id is present in an array

I'm creating an app in Angular 8.

My app uses a dialog to show a table which contains data about products, the table shows two columns [id, description], as you can see, the id column generates a checkbox and prints and id for each product.

enter image description here

This is the code that generates each checkbox and prints the ids in the table:

<ng-container matColumnDef="Id">
    <th mat-header-cell *matHeaderCellDef>Id</th>
    <td mat-cell *matCellDef="let element">
    //I assign an id to each checkbox which is the one of the element to show (A, B, C... etc)
    // and bind the method change to 'checkboxChanged', this event lets me to push the id of the checkbox to an array
        <mat-checkbox (change)="checkboxChanged($event)" id=>
            
        </mat-checkbox>
    </td>
</ng-container>
<ng-container matColumnDef="Description">
    <th mat-header-cell *matHeaderCellDef>Description</th>
    <td mat-cell *matCellDef="let element"></td>
</ng-container>

When the user clicks on each checkbox, a function called 'checkboxChanged' is fired to add/remove the id in a array (depending on the state of the checkbox).

This is the code for the logic to add the checkbox to an array:

public tempData = [];

checkboxChanged(event) {
    const id = event.source.id; //Get the id of the checkbox
    console.log(event.checked); //true or false
    console.log(id); //A, B, C... etc
    if (event.checked) this.tempData.push(id); //If checked, add to array
    else { //if unchecked, remove from the array
        const i = this.tempData.indexOf(id);
        this.tempData.splice(i, 1);
    }
console.log("tempData", this.tempData); // prinst [B, C] from the example of the screenshot 
}

After the user clicks on all the checkboxs of the products they want, they can click on 'add' to send the array to the principal screen and then process it. E. G. if the user clicks on B and C as the screenshot, the array is [B, C].

The matter is that this dialog uses Angular Material Pagination, so each time the user changes the page all the checkboxes are turn to unchecked as default, so, if I click on A and B, turn to the 2nd page and then return to the first one, the A and B checkboxes will be unchecked but the array will still be [A, B].

What I imagine for this is to make a condition when generating each checkbox so it doesn't matter if I move to another pages. This condition should be 'if the Id already exist in tempData then check the ckeckbox', something like:

<mat-checkbox (change)="checkboxChanged($event)" id= checked = ".includes()">
    
</mat-checkbox>

So the central point here is to discover how to apply this condition, maybe through an *ngIf or through the 'checked' property of the checkbox.

Could anybody help me please?:(




@if condition in input field for toggle checkbox - Laravel

My blade template contains a form where data can be inserted like name, mail, etc. One input field is a toggle checkbox where you can check whether you are an intern or not.

  • Intern => toggle checked and "Yes" is visible (equals in database 1)
  • Not intern => toggle is not checked and "No" is visible (equals in database 0)

The checking of the box is working but the status intern or extern isn't sent to the database. Bellow, you will find my code. I don't know if this is the correct way to this.

<input checked data-toggle="toggle" data-on="Yes" 
data-off="No"  data-onstyle="primary" 
data-offstyle="info" type="checkbox" 
name="intern_extern">




mardi 30 juillet 2019

How can i upload data from datalist by checkbox

I try to keep the data and insert into sql when row selected by checkbox from datalist table after user push Submit button

Checkbox Conditions

$CheckBox = $_POST["dataset"];
if(isset($_POST["Submit"]))
{
    if(empty($CheckBox) || $CheckBox == 0 ) {   
        echo "Please select data after click submit !!";
    }else{
        foreach($_POST["dataset"] as $i) 
        {
            $query = "INSERT INTO r (id,accountcode,orders)
                    VALUES('{$_POST['txtID'][$i]}','{$_POST['txtACC'][$i]}','{$_POST['txtITM'][$i]}')";
            $Q_INSERT = mysqli_query($conn,$query);                                     
        }
    }
    if($Q_INSERT)
    {
        echo "<script> alert('SUCCESS !')</script>";
    }

}

datalist table

$i=0;

while($i<$numr && $ven2 = $ven->fetch_assoc())
{

?>

<tr> 
    <td><center><input type="hidden" name="txtID[]" id="txtID" value="<?php echo $ven2["id"];?>"><?php echo $ven2["id"];?></center></td>
    <td><center><input type="hidden" name="txtACC[]" id="txtACC" value="<?php echo $ven2["acc_name"];?>"><?php echo $ven2["acc_name"];?></center></td>
    <td><input type="hidden" name="txtITM[]" id="txtITM" value="<?php echo $ven2["item_name"];?>"><?php echo $ven2["item_name"];?></td>
    <td><center><input type="checkbox" name="dataset[]" id="dataset" value="<?php echo $i++; ?>" ></center></td>  
</tr>




What is the difference b/w app:theme & android:theme in Android Programming

I have seen this that some people write

app:theme="@style/xyz"

& on the other hand some write

android:theme="@style/xyz"

What is the difference b/w these 2 codes?




How to select multiple slicer items of one slicer with different checkboxes?

My purpose: In a sheet of my file, there is a list of checkboxes that I can check in order to select specific sliceritems of the slicer 'A' located in another sheet of my file.

I succeeded to write a code in order select a slicer item of the slicer 'A' once I have selected the checkbox (for example when I click in the checkboxe 'RD' it select the slicer item 'RD' in the slicer 'A')

However, I can't select multiple slicer items of one slicer with dthe checkboxes

I tried to write a code to select one slicer item at once and it's working. When I click on a checkboxe in my sheet 'Report', the item of a slicer in a worksheet of my workbook is well selected

I tried this code

Sub CheckBox105_Click()

Dim sC As SlicerCache Dim department(0 To 21) As Variant

Set sC = ThisWorkbook.SlicerCaches("Slicer_Department")

Application.EnableEvents = False

For i = 0 To 21 department(i) = sC.SlicerItems(i + 1).Name Next i

sC.VisibleSlicerItemsList = department

        sC.SlicerItems("RR").Selected = True
        sC.SlicerItems("FD").Selected = False
        sC.SlicerItems("HG").Selected = False
        sC.SlicerItems("BP").Selected = False
        sC.SlicerItems("HH").Selected = False
        sC.SlicerItems("CO").Selected = False
        sC.SlicerItems("CO").Selected = False
        sC.SlicerItems("YH").Selected = False
        sC.SlicerItems("LI").Selected = False
        sC.SlicerItems("ED").Selected = False
        sC.SlicerItems("FI").Selected = False
        sC.SlicerItems("GM").Selected = False
        sC.SlicerItems("GU").Selected = False
        sC.SlicerItems("HR").Selected = False
        sC.SlicerItems("IT").Selected = False
        sC.SlicerItems("LE").Selected = False
        sC.SlicerItems("OP").Selected = False
        sC.SlicerItems("RK").Selected = False
        sC.SlicerItems("SRG").Selected = False
        sC.SlicerItems("BRM").Selected = False
        sC.SlicerItems("DT").Selected = False
        sC.SlicerItems("IC").Selected = False
        sC.SlicerItems("(blank)").Selected = False

Application.EnableEvents = True

With this code, the result that I expect is the following one: I select the checkboxe105 and it select the slicer item 'RD' I select the checkoxe106 and it select the slicer item 'FD' and keep the first slicer item 'RD' selected




Checkbox Functionality with Two Series of Checkboxes

I'm currently developing a form that has two containers with checkboxes. There first is the master and then there's the secondary which corresponds to the master.

The first container's checkboxes contain a data attribute value such as: "One", "Three", "Ten", etc.

Upon clicking one of the master checkboxes (the onCheck function) it checks all the input data attribute values that have an input of "checked", and then proceeds to check every checkbox in the secondary container (which has an array of information in its data attribute) and if there's a match between any of the information, they get checked.

What I'm troubleshooting is when the user unchecks a master checkbox (which is the offCheck function), because if there's a master checkbox input that's checked and it corresponds to the data information in one of the secondary checkboxes, it shouldn't be unchecked. If there's no corresponding information, it gets unchecked.

Please let me know if you need clarification as this can be a bit confusing.

HTML:

<div class="master">
  <input type="checkbox"
    data-information="One"
  /> Primary Checkbox One

  <input type="checkbox"
    data-information="Two"
  /> Primary Checkbox Two

  <input type="checkbox"
    data-information="Three"
  /> Primary Checkbox Three
</div>

<div class="secondary">
  <input type="checkbox"
    data-information='["One", "Seven", "Ten"]'
  /> Secondary Checkbox One
  <input type="checkbox"
    data-information='["Two", "Three", "Ten"]'
  /> Secondary Checkbox One
</div>

jQuery / JavaScript:

function onCheck(){
    // Gather all information from checkboxes that are checked
  var informationOne = [];
  $(".master input:checkbox").each(function(){

        if($(this).is(":checked")){
        informationOne.push($(this).data("information"));
    }

  });

  $('.secondary input:checkbox').each(function(){

    var informationTwo = [];
        informationTwo = $(this).data("information");

    for(var i=0; i<informationTwo.length; i++){

      if($.inArray(informationTwo[i], informationOne) != -1){
        $(this).prop("checked", true);
      }

    }

  });
}

function offCheck(){
}


$(".master input:checkbox").change("checked", function(){
  if($(this).is(":checked")){
    onCheck();
  } else {
    offCheck();
  }
});




Foreach function that clicks on check boxes

I need function to click on a range of check boxes. I do however not always know what i is. I tried a write a forEach loop, but it does not work:

This for loop works:

function check Boxes() {
  for (let i = 0; i < 249; i++) {
    document.getElementsByClassName("inventoryCbox")[i].click();

  }
}

and this is the non-working for loop. I think that maybe my syntax is wrong.

checkBoxes();
var boxes = document.getElementsByClassName("inventoryCbox");

function checkBoxes(node) {
  node.forEach(function(boxes) {
    boxes.click()
  });
}




I have a virtual listcontrol to which i need to add owerdrawn checkboxes

I have a virtual listcontrol which is ownerdrawn to which I need to implement multiselect feature without having to use Ctrl+click.For that reason I need to make use of ownerdrawn checkoxes.

This is an mfc application built in visualstudio 2015 version.I have tried using setextendedstyle but that doesn't go with ownerdrawn listcontrol.I have created an ownerdrawn listcontrol with icons before the listitems.Now I need to have checkboxes infront of the icons which must be ownerdrawn.Please Reply as soon as you can.Thank you.




lundi 29 juillet 2019

identification of the checkboxes in opencv in a form

enter image description hereI have been trying to identify the check-boxes in a form. I am able to find the contours of the check-boxes and extract them. I want them to have an order such that they move in a left to right and top to bottom fashion.

I cropped the contours that matched the check-boxes in the form. I want to identify the check-boxes with the key associated.

This sort the contours

def sort_contours(cnts, method="left-to-right"):
    # initialize the reverse flag and sort index
    reverse = False
    i = 0
    # handle if we need to sort in reverse
    if method == "right-to-left" or method == "bottom-to-top":
        reverse = True
    # handle if we are sorting against the y-coordinate rather than
    # the x-coordinate of the bounding box
    if method == "top-to-bottom" or method == "bottom-to-top":
        i = 1
    # construct the list of bounding boxes and sort them from top to
    # bottom
    boundingBoxes = [cv2.boundingRect(c) for c in cnts]
    (cnts, boundingBoxes) = zip(*sorted(zip(cnts, boundingBoxes),
                                        key=lambda b: b[1][i], reverse=reverse))
    # return the list of sorted contours
    return cnts

THIS GIVES THE CONTOURS IN THE IMAGE

[for c in sorted_cnts :
    peri = cv2.arcLength(c, True)
    approx = cv2.approxPolyDP(c, 0.035 * peri, True)

    (x, y, w, h) = cv2.boundingRect(approx)
    aspect_ratio = w / float(h)
    area = cv2.contourArea(c) 
    if area < threshold_max_area and area > threshold_min_area and (aspect_ratio >= 0.9 and aspect_ratio <= 1):
        cv2.drawContours(original_image,\[c\], 0, (0,255,0), 3)

        x,y,w,h = cv2.boundingRect(c)
        roi=original_image\[y:y+h,x:x+w\]
        cv2.imwrite(str(idx) + '.jpg', roi)
        print(x,y,w,h)
        checkbox_contours.append(c)][1]

I am trying to find the key along with checkbox and its status




How to set Checkbox OnCheckedChangeListener with firebaseRecyclerAdapter

I am using firebase recycler adapter to download checkbox items. However to retrieve them I would like to set a listner. OnclickedListener doesn't work. And OnCheckedListener is not accessible with the "viewHolder.itemview".

@Override
        public CheckBoxHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            CheckBoxHolder viewHolder =  super.onCreateViewHolder(parent, viewType);

                     //this variable returns null
            viewHolder.post_business_type.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    Log.d("myTagType", "type clicked ");
                    String parentID = firebaseRecyclerAdapter.getRef(editType.getChildLayoutPosition(buttonView)).getKey();
                    Log.d("myTagTypes", parentID);
                    if (isChecked) {
                        types.add(parentID);
                    } else {
                        for (int i = 0; i < types.size(); i++) {
                            if (types.get(i).equals(parentID)) {
                                types.remove(i);
                            }
                        }
                    }
                }
            });
                    //this does not work with checkbox
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.d("myTagType", "type clicked ");
                    String parentID = firebaseRecyclerAdapter.getRef(editType.getChildLayoutPosition(v)).getKey();
                    Log.d("myTagTypes", parentID);
                    if (v.isPressed()) {
                        types.add(parentID);
                    } else {
                        for (int i = 0; i < types.size(); i++) {
                            if (types.get(i).equals(parentID)) {
                                types.remove(i);
                            }
                        }
                    }

                }
            });
            return viewHolder;
        }
    };
    editType.setAdapter(firebaseRecyclerAdapter);
}

public static class CheckBoxHolder extends RecyclerView.ViewHolder {
    View view;
    AppCompatCheckBox post_business_type;
    public  CheckBoxHolder(View itemView) {
        super(itemView);
        view = itemView;
    }
    public void setType(String businessType) {
        //Log.d("myTagType", "fetching types3 ");
        post_business_type = view.findViewById(R.id.reg_checks);
        //Log.d("myTagType", "type is: " + businessType);
        post_business_type.setText(businessType);
    }
}

So I have used this same method with other items such as pictures and textviews etc. But this is the first time it is not working so I have assumed that the OnClickedListener doesn't work and need to find a way to access OnCheckedListener




How can you trigger a function if one checkbox out of multiple checkboxes is clicked

I am creating a Todo app and I need to trigger a function (which counts number of checkboxes checked) when any one of the checkboxes is checked.

I am unable to get an onlick event to happen if a checkbox is clicked. I have manage to do it with a submit button, but not with the checkbox itself

//the html
<div class="flow-right controls">
        <span>Item count: <span id="item-count">0</span></span>
        <span>Unchecked count: <span id="unchecked-count">0</span></span>
      </div>
      <button class="button center" onClick="newTodo()">New TODO</button>
      <ul id="todo-list" class="todo-list"></ul>
    </div>

// the function above this one creates the checkbox and appends it to the list in the HTML
const box = document.createElement('INPUT');
      box.type = "checkbox";
      box.name = "countme";
      box.id = "checkme"
      li.appendChild(box);

// this is the code I have created to trigger a function unchecked which returns the count of unchecked checkboxes.

let getcheck = document.getElementsByName("countme");
for (let i = 0; i < getcheck.length; i++) {
   getcheck[i].onClick = unchecked;
 }

Nothing is happening so I am unsure with how to debug this




When custom drawing a Checkbox, how can I bind my Ellipse Shape's Fill color to the CheckBox's Foreground?

I'm trying to make a CheckBox that looks like a little LED light: brightly colored when checked, gray when unchecked. In my app I need such status lights with different LED colors. I'm told the "WPF Way" is to find the control that works almost exactly like what you want, then customize it, so that's what I'm trying.

I found code for a ColorToSolidColorBrushValueConverter which will allow me to convert the CheckBox's Foreground color to a Brush to be used when filling the LED.

I honestly think the only thing I need to do now is complete the binding Path on the Ellipse's Fill property, but I haven't been able to determine the proper binding string. I've tried things like Path=Foreground, Path=Target.Foreground, Path=TargetSource.Foreground, Path=Source.Foreground, Path=Parent.Foreground--but nothing ever causes the Ellipse to show a fill color.

In my code I commented out a trigger set up to change the color when the box is unchecked, so I could be sure the trigger wasn't behaving unexpectedly and preventing me from seeing the color. I deleted the commented-out code for brevity in this post, so that's why this style as shown can currently only display the "checked" state.

          <converters:ColorToSolidColorBrushValueConverter x:Key="ColorToBrush" />

          <Style x:Key="StyleDotCheckBox" TargetType="{x:Type CheckBox}">
            <Setter Property="Template">
              <Setter.Value>
                <ControlTemplate TargetType="{x:Type CheckBox}">
                  <StackPanel Orientation="Horizontal">
                    <Ellipse x:Name="ColorDot"
                             HorizontalAlignment="Center"
                             Stretch="UniformToFill"
                             StrokeLineJoin="Round"
                             Stroke="Black"
                             Fill="{Binding Path=Foreground, Converter={StaticResource ColorToBrush}}"
                             Margin="1"
                             />
                  </StackPanel>
                </ControlTemplate>
              </Setter.Value>
            </Setter>
          </Style>


I expect the Ellipse named ColorDot to be filled in with some color at some point, but it's always blank, I think because I haven't determined the correct Path for the Fill Binding.




How to make checkbox checked on field update

I am making a form with 10 fields with 10 checkboxes. On updating the field i want relevant checkbox to be checked. I can make it work by writing 10 different ON change function but i am looking for a smart way to achieve it instead of writing 10 different ON change functions for respective fields.

<input value="1" name="checkbox-1" id="checkbox-1" type="checkbox"/>
<label for="checkbox-1"></label>
<input type="text" value="" id="field-1" name="field-1">
<label class="form-label">Field 1</label>

<input value="1" name="checkbox-2" id="checkbox-2" type="checkbox"/>
<label for="checkbox-2"></label>
<input type="text" value="" id="field-2" name="field-2">
<label class="form-label">Field 2</label>

<input value="1" name="checkbox-3" id="checkbox-3" type="checkbox"/>
<label for="checkbox-3"></label>
<input type="text" value="" id="field-3" name="field-3">
<label class="form-label">Field 3</label>

$('#field-1').bind('change', () => {
    $('#checkbox-1').prop('checked', true);
});

$('#field-2').bind('change', () => {
    $('#checkbox-2').prop('checked', true);
});

$('#field-3').bind('change', () => {
    $('#checkbox-3').prop('checked', true);
});                                                 




How I can handle multiple checkbox and basis of that show and hide input fields and update to server in react native

Please I need some help .I have 4 checkbox and I have to make that value tur or false on response basis . If its coming Y then true else false . And on click I have to change the value . If its Y and I clicked then It should be unchecked and value should be false and N is its Y then below input field will show else hide and same value I have to send in OnClick function and update to server . Please open below link and then click on updatebillprefrence edit icon the whatsaap checkbox similar thing . Below code is full page code the below of that only checkbox code .

https://xd.adobe.com/view/2b0336f6-6ff6-40ae-6653-f71e080dd0da-5d32/screen/9cb6eb49-6090-44f2-907f-c662365570f5/Android-Mobile-143?fullscreen

import React, { Component } from 'react';
    import { ImageBackground, ScrollView, TouchableOpacity, View, Platform, Image } from 'react-native';
    import { Button, Text, Item, Input, Icon, Form, ListItem, CheckBox, Body, List } from 'native-base';
    import Header from '../../ui/header';
    import TextFieldTypeClear from '../../ui/textFieldTypeClear';
    import SelectField from '../../ui/selectField';
    import { PrimaryBtn } from '../../ui/buttons';
    import BG from '../../../images/bg.jpg';
    import styles from '../../simSwap/SimSwap.style';
    import { RegularText, SmallText } from '../../ui/text';
    import { ACCOUNT_OWNER,ADDRESS,CYCLE,EMAIL,PHONE,PERIODICITY,CURRENCY,LANGUAGE,EDIT,MAIL,FAX,POST,SMS,WHATSAPP } from '../../../images';
    import _ from 'lodash';

    const styless = {
      icon:{
        marginRight:5, marginTop:3
      },
      label:{
        fontSize:14, color:'grey'
      }
    }

    const Label = ({img, textLabel}) =>{
      return (
        <View style=>
          <Image style={styless.icon} source={img}/>
          <Text style={styless.label}>{textLabel}</Text>
        </View>
      );
    }

    class UpdateBillPreferences extends Component {
      constructor(props) {
        super(props);
        const {navigation,clmmasterData} =this.props;
        this.state = {
          title: 'Update Bill Preferences',
          mobile: navigation.state.params.customer.service.serviceNumber,
          icon: 'sim',
          email: '',
          smsNum: '',
          faxNum: '',
          isBillByEmail : navigation.state.params.customerInfo[0].billingPreferenceDetails.isBillByEmail,
          isBillBySms : navigation.state.params.customerInfo[0].billingPreferenceDetails.isBillByFax,
          isBillByFax : navigation.state.params.customerInfo[0].billingPreferenceDetails.isBillBySms,
          languageAndCurrecny:{
            prefferedLanguage: navigation.state.params.customerInfo[0].billingPreferenceDetails.presentationLanguageCode,
          },
          currencyChangedValue:{
            prefferedCurrency: navigation.state.params.customerInfo[0].billingPreferenceDetails.preferedCurrencyCode,

          }

        };
      }

      componentDidMount() {

      }

      OnButtonClick = async (prefferedLanguage, preferredCurrency,email,smsNum,faxNum) => {
        const { OnButtonClick } = this.props;
        await OnButtonClick(prefferedLanguage, preferredCurrency,email,smsNum,faxNum);
        this.setState({
          preferredCurrency:'',
          prefferedLanguage:'',
          email :'',
          smsNum :'',
          faxNum :''

        })
      }
      languageChanged = (key, val) => {
        this.handleChange({ field: "prefferedLanguage" }, val);
      };

      handleChange = (props, e) => {
        let tempObj = this.state.languageAndCurrecny;
        tempObj[props.field] = e;
        this.setState({ prefferedLanguage: tempObj });
      };

      currencyChanged = (key, val) => {
        this.handleChange2({ field: "prefferedCurrency" }, val);
      };

      handleChange2 = (props, e) => {
        let tempObj = this.state.currencyChangedValue;
        tempObj[props.field] = e;
        this.setState({ prefferedCurrency: tempObj });
      };

      handleChange1 = () => {
        let isBillByEmail=this.state.isBillByEmail;
        console.log("-----------------------clicked-------");
        this.setState(previousState => {
          return { isBillByEmail: !previousState.checked };
        })
        console.log("----------isBillByEmail--------------------",isBillByEmail);

      }

      render() {
        let { title, mobile, icon,languageAndCurrecny,currencyChangedValue,isBillByEmail } = this.state;
        const { navigation,clmmasterData} = this.props;
        const {billingAddressDetails,billingPreferenceDetails} = navigation.state.params.customerInfo[0];
       const {masterData , language} = clmmasterData;
        let submitBtn = { label: 'Submit', OnSubmit: this.onSubmit };

        let currencyData=[];
        masterData.preferredCurrency.map(({ code: value, name: label }) => {
          currencyData.push({ value, label });
        });

        let languageData=[];
        masterData.language.map(({ code: value, name: label }) => {
          languageData.push({ value, label });
        });

        return (
          <ImageBackground source={BG} style={styles.imgBG}>
          <ScrollView>
            <View style={styles.container}>
              <View>
                <Header title={title} subtitle={mobile} icon={icon} navigation={navigation}/>
              </View>

                <View style={styles.contentContainer}>
                  <View style=>
                    <Form style=>
                      <SelectField
                        label="Presentation Language"
                        node="presentationLanguage"
                        options={languageData}
                        value={languageAndCurrecny.prefferedLanguage}
                        onChange={this.languageChanged}
                        that={this}
                        setIcon={true}
                        img="LANGUAGE"
                      />

                      <SelectField
                        label="Preffered Currency"
                        options={currencyData}
                        value={currencyChangedValue.prefferedCurrency}
                        node="prefferedCurrency"
                        onChange={this.currencyChanged}
                        that={this}
                        setIcon={true}
                        img="CURRENCY"
                      />
                      <View style=>
                        <View>
                          <Text style=>Preference</Text>
                        </View>
                        <View style=>
                          <View style=>
                          <CheckBox color="#00678f" checked={billingPreferenceDetails.isBillByPost === "Y" ? true : false}/>
                          </View>
                          <View style=>
                            <Text style=>Post</Text>
                          </View>
                          <View style=>
                            <CheckBox color="#00678f" checked={isBillByEmail==='Y'?true : false} onPress={() =>this.handleChange1()}/>
                          </View>
                          <View style=>
                            <Text style=>Email</Text>
                          </View>
                          <View style=>
                            <CheckBox color="#00678f" checked={true} onPress={() =>this.handleChange()}/>
                          </View>
                          <View style=>
                            <Text style=>SMS</Text>
                          </View>
                          <View style=>
                            <CheckBox color="#00678f" checked={true} onPress={() =>this.handleChange()}/>
                          </View>
                          <View style=>
                            <Text style=>FAX</Text>
                          </View>

                        </View>
                      </View>

                      <View style=>
                        <View style=>
                          <Label img={ADDRESS} textLabel="Address"/>
                        </View>
                        <View>
                        <RegularText style= text={`${billingAddressDetails.address1}, ${billingAddressDetails.address2}, ${billingAddressDetails.cityName}, ${billingAddressDetails.state}, ${billingAddressDetails.country}`} textColor="black" />

                        </View>
                      </View>

                      <View style=>
                      {billingPreferenceDetails.isBillByEmail === 'Y' &&
                        <View>
                          <Label img={EMAIL} textLabel="Email"/>
                          <Item style=>
                            <Input
                              value={this.state.email}
                              onChangeText={(text) => this.setState({email:text})}
                            />
                          </Item>
                        </View>}
                        {billingPreferenceDetails.isBillBySms === 'Y' &&
                        <View>
                          <Label img={EMAIL} textLabel="SMS"/>
                          <Item style=>
                            <Input
                              value={this.state.smsNum}
                              onChangeText={(text) => this.setState({smsNum:text})}
                            />
                          </Item>
                        </View>}
                        {billingPreferenceDetails.isBillByFax === 'Y' &&
                        <View>
                          <Label img={EMAIL} textLabel="FAX"/>
                          <Item style=>
                            <Input
                              value={this.state.faxNum}
                              onChangeText={(text) => this.setState({faxNum:text})}
                            />
                          </Item>
                        </View>}
                      </View>

                      <View style=>
                        <PrimaryBtn label={'submit'} disabled={false} onPress={()=> this.OnButtonClick(this.state.prefferedLanguage,this.state.prefferedCurrency,
                          this.state.email,this.state.smsNum,this.state.faxNum)}/>
                      </View>
                    </Form>
                  </View>
                </View>

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

    export default UpdateBillPreferences;

// Checkbox part where I am facing problem .

Props Value 

isBillByEmail: "N"
isBillByFax: "Y"
isBillByPost: "Y"
isBillBySms: "N"

     <View style=>
                        <View>
                          <Text style=>Preference</Text>
                        </View>
                        <View style=>
                          <View style=>
                          <CheckBox color="#00678f" checked={billingPreferenceDetails.isBillByPost === "Y" ? true : false}/>
                          </View>
                          <View style=>
                            <Text style=>Post</Text>
                          </View>
                          <View style=>
                            <CheckBox color="#00678f" checked={isBillByEmail==='Y'?true : false} onPress={() =>this.handleChange1()}/>
                          </View>
                          <View style=>
                            <Text style=>Email</Text>
                          </View>
                          <View style=>
                            <CheckBox color="#00678f" checked={true} onPress={() =>this.handleChange()}/>
                          </View>
                          <View style=>
                            <Text style=>SMS</Text>
                          </View>
                          <View style=>
                            <CheckBox color="#00678f" checked={true} onPress={() =>this.handleChange()}/>
                          </View>
                          <View style=>
                            <Text style=>FAX</Text>
                          </View>

                        </View>
                      </View>

                      <View style=>
                        <View style=>
                          <Label img={ADDRESS} textLabel="Address"/>
                        </View>
                        <View>
                        <RegularText style= text={`${billingAddressDetails.address1}, ${billingAddressDetails.address2}, ${billingAddressDetails.cityName}, ${billingAddressDetails.state}, ${billingAddressDetails.country}`} textColor="black" />

                        </View>
                      </View>

                      <View style=>
                      {billingPreferenceDetails.isBillByEmail === 'Y' &&
                        <View>
                          <Label img={EMAIL} textLabel="Email"/>
                          <Item style=>
                            <Input
                              value={this.state.email}
                              onChangeText={(text) => this.setState({email:text})}
                            />
                          </Item>
                        </View>}
                        {billingPreferenceDetails.isBillBySms === 'Y' &&
                        <View>
                          <Label img={EMAIL} textLabel="SMS"/>
                          <Item style=>
                            <Input
                              value={this.state.smsNum}
                              onChangeText={(text) => this.setState({smsNum:text})}
                            />
                          </Item>
                        </View>}
                        {billingPreferenceDetails.isBillByFax === 'Y' &&
                        <View>
                          <Label img={EMAIL} textLabel="FAX"/>
                          <Item style=>
                            <Input
                              value={this.state.faxNum}
                              onChangeText={(text) => this.setState({faxNum:text})}
                            />
                          </Item>
                        </View>}
                      </View>

                      <View style=>
                        <PrimaryBtn label={'submit'} disabled={false} onPress={()=> this.OnButtonClick(this.state.prefferedLanguage,this.state.prefferedCurrency,
                          this.state.email,this.state.smsNum,this.state.faxNum)}/>
                      </View>
                    </Form>
                  </View>
                </View>

Please help..Thanks




dimanche 28 juillet 2019

How to get array values if checked or not one by one on a form?

I have a simple form, i would like to get all array values one by one and print on PHP. I'll be so happy if you help me.

<php
if(isset($_POST['submit'])){
    if(!isset($error)){
    try {

                if($_POST['mod_[1]']=="1"){
                    $mod_1 = '1';
                    $mod_1_symbol = "✓";
                }else{
                    $mod_1 = '0';
                    $mod_1_symbol = "X";
                }

                if($_POST['mod_[2]']=="1"){
                    $mod_2 = '1';
                    $mod_2_symbol = "✓";
                }else{
                    $mod_2 = '0';
                    $mod_2_symbol = "X";
                }

                if($_POST['mod_[3]']=="1"){
                    $mod_3 = '1';
                    $mod_3_symbol = "✓";
                }else{
                    $mod_3 = '0';
                    $mod_3_symbol = "X";
                }

                if($_POST['mod_[4]']=="1"){
                    $mod_4 = '1';
                    $mod_4_symbol = "✓";
                }else{
                    $mod_4 = '0';
                    $mod_4_symbol = "X";
                }

                if($_POST['mod_[5]']=="1"){
                    $mod_5 = '1';
                    $mod_5_symbol = "✓";
                }else{
                    $mod_5 = '0';
                    $mod_5_symbol = "X";
                }
}catch(PDOException $e) {
            $error[] = $e->getMessage();
        }
    }
}
?>

<form role="form" method="post" action="" enctype="multipart/form-data" class="contact-form">
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input type="checkbox" id="mod_1" name="mod_[]" value="1" />
<input name="submit" type="submit" value="Send">
</form>

i need to get some thing like this: if mod_[1] checked write 1 else 0;

if mod_[2] checked write 1 else 0;

Something like this.




Simulate MouseEvents in Tampermonkey to select checkboxes

I need to simulate a whole click to fill in a list of check boxes.

not just

checkThem([].slice.call(document.querySelectorAll('input[type="checkbox"]')));


function checkThem(nodes) {
    nodes.forEach(function(n) { n.checked = true });```

}

or

checkThem([].slice.call(document.querySelectorAll('input[type="checkbox"]')));


function checkThem(nodes) {
    nodes.forEach(function(n) { n.click()});
    // document.getElementsById ("SyncInventory")[0].click();```
}

I tried using an entire MouseEvents but nothing works. The check boxes are not even checked as in the previous examples.

simulateMouseClick([].slice.call(document.querySelectorAll('input[type="checkbox"]')));


    function simulateMouseClick(targetNode) {
        function triggerMouseEvent(targetNode, eventType) {
            var clickEvent = document.createEvent('MouseEvents');
            clickEvent.initEvent(eventType, true, true);
            targetNode.dispatchEvent(clickEvent);
        }
        ["mouseover", "mousedown", "mouseup", "click"].forEach(function(eventType) { 
            triggerMouseEvent(targetNode, eventType);
        });
    }




samedi 27 juillet 2019

How do I see if a specific CheckBox is selected within a GridPane?

I've created a 10x10 GridPane of CheckBoxes. I need to see whether a specific CheckBox is selected, but the GridPane is made up of nodes. So If I access a particular node using a function from another thread, I can't use isSelected because it is the wrong type.

I've tried modifying the function getNodeByRowColumnIndex or forcing the type to be CheckBox but I'm not sure how.

@FXML
private GridPane Grid;

@FXML
public void initialize() {
    for (int x = 0; x < 10; x++) {
        for (int y = 0; y < 10; y++) {
            this.Grid.add(new CheckBox(), x, y);
            //Problem here
            boolean bln = getNodeByRowColumnIndex(y,x,this.Grid).isSelected();
        }
    }
}




How to stop check boxes aligning to their text

As you can see in THIS picture: i have 2 check boxes with a text attribute, the issue here is that since the text is not equal and the boxes are centered to the middle the box actually moves to keep it in the middle. Is there any way to make it so that only the text moves and the box stays in a static location like THIS but without aligning it to anything except the middle. Snippet of the checkbox in the fxml file:

           <JFXCheckBox checkedColor="#8d897d00" focusTraversable="false" graphicTextGap="0.0" prefHeight="35.0" prefWidth="690.0" styleClass="runechanger-check-box" stylesheets="@../stylesheet.css" text="No Away" textFill="#8d897d" unCheckedColor="#8d897d00" GridPane.rowIndex="1">
           <font>
              <Font name="System Bold" size="18.0" />
           </font>
        </JFXCheckBox>

THIS is the full fxml containing the checkboxes




vendredi 26 juillet 2019

checkbox checked true is not visible, box is not visible text is visible

my check box when checked is true it is not showing the box(image) when checked is untrue it is showing the empty box

tried changing visibility and selected true and false but nothing changed

I want a tick mark to be displayed when selected is true and empty box when selected is false this is the coding image

this is the output image




pseudo captcha with two checkboxes one for humans one for bots

I am trying to create a pseudo captcha to stop spambots spamming my contact form. I have php so that it doens't allow the user to send if the form isn't filled out and instead gives a message. I'm trying to make it so that it doesn't send if the "I am a robot" checkbox is checked as well. Since bots tend to check all checkboxes, I figured this may work. I am pretty new to PHP so go easy on me.

I tried using !empty($robots) which didn't work. I also tried !isset($robots) I messed with a second IF statement.

<?php
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$client_message = $_POST['client_message'];
$to = "rtisticpictures@gmail.com";
$subject = "Client Message";
$cmessage = $_POST['client_message'];

$message = $first_name . " " . $last_name . "\n\n Phone:" . $phone . "\n\n email:" . $email . "\n\n" . $cmessage;
if(empty($first_name) || empty($last_name) || empty($phone) || empty($cmessage) || empty($email))
{
echo "Your message can not be sent without all fields filled in, or you have checked that you are a robot. We do not allow bots to send email.";
;  // Note this
}
else
{
mail ($to, $subject, $message, "From: " . $first_name . $last_name);
echo "Your message has been Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
?>

HTML FORM
<form action="contact_form.php" method="post" name="contact_form">
<p>First Name: <input name="first_name" type="text" />
   Last Name: <input name="last_name" type="text" />
   Phone Number: <input name="phone" type="text" placeholder="(999)999-9999" />
   E-mail:<input name="email" type="text" placeholder="your@email.com" />
</p>
<p>
    <textarea name="client_message" cols="5" rows="3" placeholder="Write your message here."></textarea>&nbsp;
</p>
<div class="6u 12u(2)">
    <input type="checkbox" id="human" name="human" unchecked="">
    <label for="human">I am not a robot.</label></div>
    <div class="6u 12u(2)">
    <input type="checkbox" id="robots" name="robots" unchecked="">
    <label for="robots">I am a robot.</label>
</div>
<p>
    <input type="submit" name="submit" id="submit" value="Send"/>
    <input type="reset" name="reset" id="reset" value="Clear"/>
</p>
</form> 

I would like it to send only when the 'human' checkbox is selected and the 'robots' checkbox is not selected.




Group checkbox in Antd by using array object

Here is the original example of group checkbox of antd that I need and its fine:

const plainOptions = ['Apple', 'Pear', 'Orange'];
const defaultCheckedList = ['Apple', 'Orange'];

class App extends React.Component {
  state = {
    checkedList: defaultCheckedList,
    indeterminate: true,
    checkAll: false,
  };

  onChange = checkedList => {
    this.setState({
      checkedList,
      indeterminate: !!checkedList.length && checkedList.length < plainOptions.length,
      checkAll: checkedList.length === plainOptions.length,
    });
  };

  onCheckAllChange = e => {
    this.setState({
      checkedList: e.target.checked ? plainOptions : [],
      indeterminate: false,
      checkAll: e.target.checked,
    });
  };

  render() {
    return (
      <div>
        <div style=>
          <Checkbox
            indeterminate={this.state.indeterminate}
            onChange={this.onCheckAllChange}
            checked={this.state.checkAll}
          >
            Check all
          </Checkbox>
        </div>
        <br />
        <CheckboxGroup
          options={plainOptions}
          value={this.state.checkedList}
          onChange={this.onChange}
        />
      </div>
    );
  }

}

My question is how can I replace the plainOptions and defaultCheckedList by object array instead of simple array and using attribute name for this check boxes? For example this object:

const plainOptions = [
  {name:'alex', id:1},
  {name:'milo', id:2},
  {name:'saimon', id:3}
];
const defaultCheckedList = [
  {name:'alex', id:1},
  {name:'milo', id:2}
];

I want to use attribute name as the key in this example.




How to check and uncheck all checkboxes in WebGrid column?

Is there any reason why this is not working to check and uncheck the checkboxes? If I don't touch any of the checkboxes, it checks and unchecks them all on the button click event. If I manually check a box, that box will not be modified from then on, however the rest of them will continue to be modified.

How do I solve the problem?

function checkAll() {
  $('#grid tbody tr').each(function () {
    if ($(this).find("td input[type=checkBox]").is(":checked")) {
      $(this).find("td input[type=checkBox]").removeAttr("checked");
      //$(this).find("td input[type=checkBox]").attr("checked", false); //also tried this
    }
    else {
      $(this).find("td input[type=checkBox]").attr("checked", true);
    }
  });
}




Trying to change picture(actually checkbox) when item clicked and save it in a custom listview with adapter

Im trying to change the picture(i mean one pic is a "checked box" and the other one "blank box") so when user clicks on an item in the listview the blank box will turn to "checked" box. I could do it with the dafault checkbox that android studio offers but i began to do it this way and i dont understand why my code doesnt do the work with "pictures"instead of default checkbox. By the way the code is letting user choos only one box. After having selected the item i tried to save the state with sharedpreferences but it didnt go well. Eveytime i start the app i see unchecked,blank boxes. I would appreciate any help. Thank you. Heres my code :

CUSTOMADAPTER

       public class CustomAdapter extends BaseAdapter {

 Activity activity;
List<UserModel> users;
LayoutInflater inflater;
CheckBoxActivity c=new CheckBoxActivity();

public CustomAdapter(Activity activity) {
    this.activity = activity;
}

public CustomAdapter(Activity activity, List<UserModel> users) {
    this.activity = activity;
    this.users = users;
    inflater = activity.getLayoutInflater();

}


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

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

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

@Override
public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder holder = null;
    if (view == null) {
        view = inflater.inflate(R.layout.list_view_item, viewGroup, false);
        holder = new ViewHolder();
        holder.tvUserName = view.findViewById(R.id.tv_user_name);
        holder.ivCheckBox = view.findViewById(R.id.iv_check_box);
        view.setTag(holder);
    } else {
        holder = (ViewHolder) view.getTag();
        UserModel model = users.get(i);
        holder.tvUserName.setText(model.getUserName());
        if (model.isSelected) {
            c.switchOnOff=true;
            holder.ivCheckBox.setBackgroundResource(R.drawable.ic_check_box_black_24dp);

        } else {
            c.switchOnOff=false;

            holder.ivCheckBox.setBackgroundResource(R.drawable.ic_check_box_outline_blank_black_24dp);

        }

    }
    return view;
}

public void updateRecords(List<UserModel> users) {
    this.users = users;
    notifyDataSetChanged();
}

class ViewHolder {

    TextView tvUserName;
    ImageView ivCheckBox;
}

}

CheckBoxActivity

    public class CheckBoxActivity extends Activity {
    int preSelectedIndex =-1;
    public static final String SHARED_PREFS = "sharedPrefs";
    public static final String TEXT = "text";
    public static final String SWITCH1 = "switch1";
    private String text;
    public boolean switchOnOff;

   @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.singleselectionlistview);

     ListView listView=findViewById(R.id.singleselectionlistview);
    //CheckBox cb = (CheckBox) findViewById(R.id.iv_check_box);
    final List<UserModel> users=new ArrayList<>();
    users.add(new UserModel(false,"Dharm"));
    users.add(new UserModel(false,"Dharm"));
    users.add(new UserModel(false,"Dharm"));
    users.add(new UserModel(false,"Dharm"));
   final CustomAdapter adapter=new CustomAdapter(this,users);
  listView.setAdapter(adapter);

  listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  @Override
  public void onItemClick(AdapterView<?> parent, View view, int i, long 
   l) {
    UserModel model=users.get(i);
   model.setSelected(true);
    users.set(i,model);

   if(preSelectedIndex>-1){
    UserModel preRecord=users.get(preSelectedIndex);
     preRecord.setSelected(false);
     users.set(preSelectedIndex,preRecord);

    }
   preSelectedIndex=i;
  adapter.updateRecords(users);




     }
   });
    }
   public void saveData() {
    SharedPreferences sharedPreferences = 
    getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    SharedPreferences.Editor editor = sharedPreferences.edit();

    //editor.putString(TEXT, tv.getText().toString());
    editor.putBoolean(SWITCH1, switchOnOff);
    editor.apply();
    Toast.makeText(this, "data saved", Toast.LENGTH_SHORT).show();

   }
  public void loadData() {
    SharedPreferences sharedPreferences = 
    getSharedPreferences(SHARED_PREFS, MODE_PRIVATE);
    switchOnOff = sharedPreferences.getBoolean(SWITCH1, false);
  }
    public void updateViews(){
    //tv.setText(text);
    //sw.setChecked(switchOnOff);

   }
   }




yii2 checkbox is not showing but label is visible

     <?= $form->field($model, 'term_condition')->checkbox(); ?>

It is not showing the checkbox but it shows the label.

and I looked into the generated html and that is also fine.here is the generated html.

<div class="form-group field-dynamicmodel-term_condition">
<input type="hidden" name="DynamicModel[term_condition]" value="0"><label> . 
    <input type="checkbox" id="dynamicmodel-term_condition" 
     name="DynamicModel[term_condition]" value="1"> Term Condition</label>
<div class="help-block"></div>




jeudi 25 juillet 2019

Child element onlick in parent element onlick

I have a "checkbook" in a "div tag", "div tag" that has been registered an onclick event, when I clicked on the checkbox, it will call the event of "div tag", how to just catch the event of "checkbook ", I tried "z-index" for checkbok but did not work




Android checkbox remove the box keep the text

I am using a custom background color that changes depending on the state of the checkbox so my background property is already used. Most advices tell me to set the background to @null. I just want to keep the text and remove the box on the left.




How do I clear the checkbox check? The value is being cleared

I have two checkboxes which help filter data. I have a function which clears the filter, but the checkboxes remain checked.

I tried ngModel, but with no success.

<label class="filterlable" for="">Other:</label>&nbsp;&nbsp;
                    <label><input id="CPRBox" type="checkbox" [value]="3" [checked]="CPRBox" (change)="includeOthers(3)">&nbsp;CPR Certified&nbsp;</label>
                    <label><input id="NotaryBox" type="checkbox" [value]="2" [checked]="NotaryBox" (change)="includeOthers(2)">&nbsp;Notary&nbsp;</label>

This sets the value when the box is clicked:

includeOthers(id): void {
    const index = this.otherArray.indexOf(id);
    if (index == -1) {
      this.otherArray.push(id);
    } else {
      this.otherArray.splice(index, 1);
    }
    this.addQueryParams({ other: this.otherArray.length > 0 ? this.otherArray.toString() : null })
  }

This clears the filter, but the box(es) remain checked.

clearFilters() {
    this.otherArray = [];
    this.CPRBox = false;
    this.NotaryBox = false;
  }

When clearFilters() runs, the checkboxes should no longer be checked.

Right now, the filters are cleared, but the boxes remain checked. Which means, when the user clicks on the boxes a 2nd time, the filters are enabled, but the boxes are not checked, leading to a confusing state of the filter.




Angular form invalid when checkbox unchecked then checked

I have a form that has three checkboxes, which are checked by default. If a uncheck the checkbox, and enter a value in the form below it and then submit, everything works fine.

If I uncheck one of the checkboxes then check it again and click submit, it says that the form is invalid.

https://angular-khmzeq.stackblitz.io

<form [formGroup]="form" autocomplete="off">
    <h2>Terms</h2>
    <div *ngIf="!this.input.data.acceptDate" [class.entry]="!form.get('acceptDate').value">
        <mat-checkbox class="checkbox" formControlName="acceptDate"><strong>I accept the date</strong>
        </mat-checkbox>
        <br />
        <br />
        <mat-form-field *ngIf="!form.get('acceptDate').value">
            <input matInput [matDatepicker]="optDate" placeholder="Preferred date" formControlName="optDate" [min]="now" required />
            <mat-datepicker-toggle matSuffix [for]="optDate"></mat-datepicker-toggle>
            <mat-datepicker #optDate></mat-datepicker>
        </mat-form-field>
    </div>

    <div *ngIf="!this.input.data.acceptPod" [class.entry]="!form.get('acceptPod').value">
        <mat-checkbox class="checkbox" formControlName="acceptPod"><strong>I accept the point of delivery</strong> 
        </mat-checkbox>
        <br />
        <br />
        <mat-form-field *ngIf="!form.get('acceptPod').value">
            <input matInput formControlName="optPod" type="text" placeholder="Preferred point of delivery" required />
        </mat-form-field>
    </div>

    <div [class.entry]="!form.get('acceptPrice').value">
        <mat-checkbox class="checkbox" formControlName="acceptPrice"><strong>I accept the price</strong> 
        </mat-checkbox>
        <br/>
        <br/>
        <mat-form-field *ngIf="!form.get('acceptPrice').value">
            <input matInput formControlName="price" type="number" placeholder="Price per " required />
            <span matSuffix></span>
        </mat-form-field>
    </div>

</form>

async submitCounter({ valid, value }) {
      if(valid) {
// submit form
    }

    if(!valid){
      console.log('not valid');
    }
  }




How to use sub in created checkbox

I am doing some stuff in excel VBA and I got a problem. When I clic on a button, ActiveX checkbox is created (I need this checkbox for some other task) and I would like to have that when the checkbox is "true" the background color is green (when false it's red). I know how to code this manualy into checkbox created by me. But I dont know how to assign this code to checkbox created by vba. thank you for answers :)




Angular form not working if checkbox is unchecked then checked

I have a form that has three checkboxes, which are checked by default. If a uncheck the checkbox, and enter a value in the form below it and then submit, everything works fine.

If I uncheck one of the checkboxes then check it again and click submit, it doesn't work...

<form [formGroup]="form" autocomplete="off">
    <h2>Terms</h2>
    <div *ngIf="!this.input.data.acceptDate" [class.entry]="!form.get('acceptDate').value">
        <mat-checkbox class="checkbox" formControlName="acceptDate"><strong>I accept the date</strong>
        </mat-checkbox>
        <br />
        <br />
        <mat-form-field *ngIf="!form.get('acceptDate').value">
            <input matInput [matDatepicker]="optDate" placeholder="Preferred date" formControlName="optDate" [min]="now" required />
            <mat-datepicker-toggle matSuffix [for]="optDate"></mat-datepicker-toggle>
            <mat-datepicker #optDate></mat-datepicker>
        </mat-form-field>
    </div>

    <div *ngIf="!this.input.data.acceptPod" [class.entry]="!form.get('acceptPod').value">
        <mat-checkbox class="checkbox" formControlName="acceptPod"><strong>I accept the point of delivery</strong> 
        </mat-checkbox>
        <br />
        <br />
        <mat-form-field *ngIf="!form.get('acceptPod').value">
            <input matInput formControlName="optPod" type="text" placeholder="Preferred point of delivery" required />
        </mat-form-field>
    </div>

    <div [class.entry]="!form.get('acceptPrice').value">
        <mat-checkbox class="checkbox" formControlName="acceptPrice"><strong>I accept the price</strong> 
        </mat-checkbox>
        <br/>
        <br/>
        <mat-form-field *ngIf="!form.get('acceptPrice').value">
            <input matInput formControlName="price" type="number" placeholder="Price per " required />
            <span matSuffix></span>
        </mat-form-field>
    </div>

</form>




Select several checkboxes at once that seems to be images

Instead of manually selecting the check boxes of several pages,

I am using TamperMonkey to select all the check boxes with a small Javascript function.

The checkboxes get selected but the next step (SyncNow)for the procedure is greyed out.

I think it has to do with changing classes.

  1. Is there another way to select the checkboxes with a 'click' via TamperMonkey?

or

  1. How do I add an extra class that will hopefully not grey out the next step?

You can see the code that I have here:

https://codepen.io/Marina_2019/pen/dxXmZL

I tried this, and it did not work:

   function selectAll(){

            document.getElementById("AllInventorySelected").checked = true;

    }
}, false);

This function worked:

checkThem([].slice.call(document.querySelectorAll('input[type="checkbox"]')));


function checkThem(nodes) {
    nodes.forEach(function(n) { n.checked = true });
}

The problem is that the next after selecting all the check boxes are greyed out (unless I do it manually).

I noticed that a class gets added if I select the check boxes manually.

Code snippets are here:

https://codepen.io/Marina_2019/pen/dxXmZL




multiple checkbox update and insert data current date last 2 pervious date

enter image description here

This is my frontend file view. Problem is in this part Please help me. Thanks in advance.




How to store and retrieve checked treeview checkbox in using localstorage or cookies?

I have a hierarchical structured treeview with checkboxes and i would like to store the checked checkbox into either localstorage or cookies then retrieved it back. It work fine with normal checkbox but not when combined treeview and checkbox.

JavaScript for localStorage

jQuery(function()
     {if (localStorage.input)
        {var checks = JSON.parse(localStorage.input);
            jQuery(':checkbox').prop('checked', function(i)
              {return checks[i];
              });
            }
    });

    jQuery(':checkbox').on('change', function() 
    {localStorage.input = JSON.stringify(jQuery(':checkbox').map(function()
        { this.checked;
        }).get());
   });

JavaScript for Kendo Treeview with checkbox

homogeneous = new kendo.data.HierarchicalDataSource({
                    transport: {
                        read: {
                            url: serviceRoot,
                            dataType: "json"
                        }
                    },
                    schema: {
                        model: {
                            id : "ehorsProgramID",
                            hasChildren: false,
                            children : "items"
                        }
                    },

                    filter: { field: "module", operator: "startswith", value: "Accounting" }
                });

            $("#AccountingTree").kendoTreeView({
                check: onCheck,
                checkboxes: { checkChildren: true } ,
            //  select: onSelect,
                dataSource: homogeneous,
                    dataBound: function(){
                        this.expand('.k-item');
                    },
                dataTextField: ["module","groupname","ehorsProgramName"]
            });

Anyone have opinion on this?




mercredi 24 juillet 2019

Why can't I change my disabled checkbox to enable?

Simple question, so I made sure to try and a lot of solutions before posting this. I have a checkbox and I can't seem to enable it.

With vanilla JS, I've tried removing the attribute, as well as setting the disabled flag to false, and also using jQuery i've tried to use the Prop to no success.

'''html

<input type="checkbox" id="chkAllowToAdminService" name="chkAllowToAdminService" disabled="disabled" data-init-plugin="switchery">

'''

I've tried the following and none of them are working (vanilla JS and jQuery)

'''

document.getElementById('chkAllowToAdminService').disabled = false;
document.getElementById('chkAllowToAdminService').removeAttribute('disabled);
$('#chkAllowToAdminService').prop("disabled", false);

'''

No error messages at all, just nothing seems to be happening.




Change character used for separation of form input fields with same name identifier?

I have a form which has a bunch of checkboxes like this:

<input type="checkbox" name="input1" value="A, and B"/>A, and B
<input type="checkbox" name="input1" value="C"/>C

I also have some JQuery code that populates the already selected fields using JSTL like this:

$('input[name="input1"]').val("${form_inputs}".split(','));

The thing is since the value "A, and B" contains a comma, the jquery is splitting and setting the checkbox checked states wrong.

I already tried adding more commas so I could split at ",," but it doesnt seem to want to work.

Is there any way to change the comma splitter character to a different character?




How can I seleced a checkbox from recyclerview layout click

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

???????? } });

    holder.plus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            CheckBox cb = (CheckBox) view;
            Artikel contact = (Artikel) cb.getTag();

            contact.setSelected(cb.isChecked());
            mArtikelList.get(pos).setSelected(cb.isChecked());
        }
    })

For the checkbox(hoder.plus)is working fine.




Powershell: Get content from checked checkbox

My problem is the following: I create a checkbox with the code displayed and a button. If I click the button, the checked items shell be put into the $selectedCusts array. But whatever I've tried - Nothing worked.

Any help is appreciated. :-)

Thanks in advance german_erd

$cbheight = 0
foreach ($c in $customer)
{
    $cbheight                       += 20
    $checkBox                       = New-Object System.Windows.Forms.checkBox 
    $checkBox.Font                  = "Microsoft Sans Serif,14"
    $checkBox.Name                  = "$c"
    $checkBox.Text                  = "$c"
    $checkbox.Location              = new-object System.Drawing.Size(20,$cbheight)
    $checkbox.Size                  = new-object System.Drawing.Size(345,23)
    $checkBox.SendToBack()
    $objForm.Controls.Add($checkBox)
}

[…]
$AllCustButton.Add_Click({ 
$selectedCusts = ???

})




Ionic 4: Ion-checkbox checked not updating from ionchange

This is how I create a list with checkboxes to check/uncheck employees. I am binding the checked property of an employee to the checkbox.

<ion-list>
    <ion-item *ngFor="let employee of employees; let i = index">
        <ion-label></ion-label>

        <ion-checkbox  value=""  
                                 [(ngModel)]="employee.isChecked"
                                 (ionChange)="emplsChange($event.detail.checked, i)"></ion-checkbox>
    </ion-item>
</ion-list>

However, when the checkbox is changed, I want to check if it can be checked or has to be false. In order to do that, I set the isChecked property of the selected employee to false after I’ve checked the conditions.

    emplsChange(detail: boolean, index: number) {
        const newEmployees: IEmployee[] = this.employees;
        this.employees = [];
        // get all checked employees
        const checkedEmpls = newEmployees.filter(e => e.isChecked).length;

        newEmployees[index].isChecked = detail && checkedEmpls === this.needdedEmpls ? false : detail;

        this.employees = newEmployees;
    }

Now, the thing is, that if the condition is true and I set the isChecked to false it works correctly and the checkbox is not checked. But only on the first time. If I check the same employee again the isChecked is set to false but on the UI it is checked.

I’ve tried to solve this by using (ngModelChange) instead of (ionChange) but it did nothing to it.

So the main Problem is, that the UI is not properly updated, when I set the ion-checkbox-Model in the onchange method of the component. Can one of you see another problem? Did someone experienced the same? CaN Som3One plZ HeLp!1!!!11

Thx

I am using Ionic:

Ionic CLI : 5.2.1 Ionic Framework : @ionic/angular 4.7.0-dev.201907122213.5db409f @angular-devkit/build-angular : 0.801.1 @angular-devkit/schematics : 8.1.1 @angular/cli : 8.1.1 @ionic/angular-toolkit : 2.0.0




Centering the checkbox in a line CSS

I would like to center the checkbox in a line with text next to it.

I've tried already style="text-align: center;" in <div> but it doesn't work

CSS

input {
    font-size: 16px;
}

label {
    font-size: 11px;
    vertical-align: middle;
}

form {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

input[type="checkbox"] {
    width: 15px;
    height: 15px;
    -webkit-appearance: none;
    background: white;
    outline: none;
    border: none;
    border-radius: 50%;
    transition: .5s;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, .2)
}

input:checked[type="checkbox"] {
    background-color: transparent;
}

HTML

<form class="form-box__form form">
    <input type="e-mail" name="e-mail" id="e-mail" placeholder="e-mail"/>
    <input type="password" name="password" id="password" placeholder="password"/>
    <button>Create account</button>
    <div style="text-align: center;">
    <input type="checkbox" name="consent" id="consent"/>
    <label for="consent">I agree to whatever you want me to agree</label>
    </div>
</form>

at this moment it looks like this enter image description here




Refresh page call back the selected checkboxes Kendo in treeview

Here, I supposed to click the checkboxes then I send the data into database using submit button (AJAX). After click on submit button, it will be refresh the page but all the selected checkboxes gone. How I do to keep the selected checkboxes after refresh the page? Any idea or guide to do it?

AJAX

//AJAX call for button
    $("#primaryTextButton").kendoButton();
    var button = $("#primaryTextButton").data("kendoButton");
    button.bind("click", function(e) {

    var test = $("#dropdown").val()

    $.ajax({
        url: "../DesignationProgramTemplate/getTemplate.php",
        type: "post",
            data: {'id':test,'progid':array},
                success: function () {
                // you will get response from your php page (what you echo or print)                 
                    kendo.alert('Success'); // alert notification
                    //refresh
                    //location.reload("http://hq-global.winx.ehors.com:9280/ehors/HumanResource/EmployeeManagement/DesignationProgramTemplate/template.php");
                },
        });
    });

PHP for getTemplate

$employeeID = $_SESSION['employeeID'];
$propertyID = $_SESSION['propertyID'];
$id = $_POST['id'];
$progid = $_POST['progid'];

for($x=0; $x< sizeof($progid); $x++ )
{
    $array = array();   

$positionTemplateID = $ehorsObj->EHORS_PK("tblHrsPositionProgramTemplate"); 
$sqlAdd = "INSERT INTO tblHrsPositionProgramTemplate 
            SET positionTemplateID = '" . $positionTemplateID . "',
            programID = '" . $progid[$x] . "',
            hrsPositionID  = '" . $id . "',
            propertyID   = '" . $propertyID . "',
            employeeID  = '" . $employeeID . "',
            dateTimeEmployee = NOW() ";     

$ehorsObj->ExecuteData($sqlAdd, $ehorsObj->DEFAULT_PDO_CONNECTIONS);

$positionTemplateIDLog = $ehorsObj->EHORS_PK("tblHrsPositionProgramTemplateLog");   
$sqlAddLog = "INSERT INTO tblHrsPositionProgramTemplateLog 
            SET positionTemplateIDLog = '" . $positionTemplateIDLog . "',
            positionTemplateID = '" . $positionTemplateID . "',
            programID = '" . $progid[$x] . "',
            hrsPositionID  = '" . $id . "',
            propertyID   = '" . $propertyID . "',
            employeeID  = '" . $employeeID . "',
            dateTimeEmployee = NOW() ";     

$ehorsObj->ExecuteData($sqlAddLog, $ehorsObj->DEFAULT_PDO_CONNECTIONS);
}

Function for checkboxes

function checkedNodeIds(nodes, checkedNodes) {
  for (var i = 0; i < nodes.length; i++) {
    if (nodes[i].checked) {
      //checkedNodes.push(nodes[i].moduleID);
     // checkedNodes.push(nodes[i].groupID);
      checkedNodes.push(nodes[i].id);
    }

    if (nodes[i].hasChildren) {
      checkedNodeIds(nodes[i].children.view(), checkedNodes);
    }
  }

}

Anyone have the idea about it?

Output




mardi 23 juillet 2019

Reposition checkbox check with long label when white-space: normal Angular Material

I have an Angular Material Checkbox with a long label. When I set white-space: normal for the checkbox, it confines the text to an outer div, however, it aligns the checkbox check center left with the text, and I would like to align the checkbox check to top left.

<mat-checkbox color="primary">
    This is a checkbox with a really long label, I want to wrap on new lines, but also want to align the checkbox check to top left, and it defaults to center left.
</mat-checkbox>

This fixes the issue with the text being on a single line, however, results in the checkbox check being aligned center left, and I want to move it to top left.

::ng-deep .mat-checkbox-layout {
   white-space: normal !important;
}

I would like to be able to re-position the checkbox check to top left, instead of the default center left.




checkboxGroupInput displaying list of table elements rather than table itself

I am creating an R Shiny application primarily using checkboxGroupInput where for each checkbox name I check, the corresponding table should display in the main UI panel. I have linked each checkbox option to its corresponding table (already in my previous script) in the "choices" argument of checkboxGroupInput. I use eventReactive to make a working button and renderTable to produce the appropriate tables. However, what displays in the main panel when I click the button is a list of each cell in the table rather than the table itself. This list of values looks a bit like this:

list(CUI = "C05372341", LAT = "ENG", TS = "P", LUI = "L0883457", STT = "PF", SUI = "S13423408", ISPREF = "N", AUI = "A10344304", SAUI = "21823712", SCUI = "1341953", SDUI = NA, SAB = "LKDHDS", TTY = "IN", CODE = "139433", STR = "Pramlintide", SRL = "0", SUPPRESS = "Y", CVF = "4354")

I would like this to have been printed in table form.

When I simply use renderTable({table_name}) on any given one of the tables, the table prints in the main panel how I would like it to. However, when I use eventReactive, name that variable, and renderTable on that variable, that is when the list of table values prints instead. Any ideas?

library(shiny)

ui <- fluidPage(
  titlePanel("RxNorm Diabetic Drug Mapping based on Epocrates Classes"),
  sidebarLayout(
    sidebarPanel(
      checkboxGroupInput("drugs", "Drug Class", choices = list("ALPHA GLUCOSIDASE INHIBITORS" = agi, "AMYLIN MIMETICS" = pramlintide, "BIGUANIDES" = biguanides, "DOPAMINE AGONISTS" = bromocriptine, "DPP4 INHIBITORS" = dpp4, "GLP1 AGONISTS" = glp1, "INSULINS" = insulins, "MEGLITINIDES" = meglitinides, "SGLT2 INHIBITORS" = sglt2, "SULFONYLUREAS" = sulfonylureas, "THIAZOLIDINEDIONES" = thiazolidinediones)), 

      actionButton("button", "Retrieve Data")
    ),

    mainPanel(
      tableOutput("results")
    )
  )
)

server <- function(input, output) {
   table_reactive <- eventReactive(input$button, {
     input$drugs
   })

   output$results <- renderTable({
     table_reactive()
   })
}

shinyApp(ui = ui, server = server)




Fill in a textbox according to checkbox and option selection (don't even know if i'm creating it the best way

On a userform I am trying to populate a textbox with cell value according to a checkbox and optionbutton combination.

The bigger picture is i'm trying to create a macro that will automatically create emails.

Firstly I have 7 checkboxes (Applications) , one could be ticked or a couple could be ticked. Then it is the type of email I would like to create, for this I have used optionbuttons.

Not necessarily after code (though that would be helpful) but just need some guidance on how to code it as I have written and then re-written so much code and the last one was way over the top for what I needed.

Any advice much appreciated




How to add checkBox for variables group with tabPanel in R shiny

.Hi, I need help in adding variables checkbox in r shiny within the tabPanel. I have already developed an r shiny app, in which on one of the page the data is displayed on the basis of some filterers and keywords search box.

So, I want to include one checkbox group of variables for the uploaded file. I saw some of the solution but, non of them is based on tabPanel. Is it possible to have variable checkBox with tabPanel and how to place this under UI and SERVER. Also, as rest of the development is done so, would like to have solution with tabPanel if possible. Thanks

Tried adding the checkBoxInput but with not working with tabPanel and disturbing the current tabPanel




lundi 22 juillet 2019

Checkbox state always stay checked

If I open the activity, the checkbox always stay checked and even if I unchecked it and leave the activity or closed the app it'll stay checked again after restarting the activity.

I've tried saving the state of the activity using the below code snippet.

checkBox1.setChecked(getSharedPreferences("NSUK", Context.MODE_PRIVATE).getBoolean("checkBox1", true));

        checkBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                getSharedPreferences("NSUK", Context.MODE_PRIVATE).edit().putBoolean("checkBox", isChecked).apply();

            }
        });

The checkbox is expected to always be in the state that the user leave it (checked or unchecked).




I need checkboxes in combine to act as an AND, not as an OR

I used to be a programmer but did not program for 15 years so I am pre-web. I spent the last 2 days learning HTML and CSS to put together this: https://www.visualdiaryguide.com/selector.html

The problem is when I check the boxes, I need the selections to reflect the combination of Art Forms and Styles, not a collection. For example, when I click 2D-Painting and Realism, white selections should be reduced not expanded.

It feels like I'd need to re-design this whole thing (which I am hoping is not the case). I don't really want to also learn JavaScript :(

Any suggestions would be appreciated. I am assuming you can see the HTML and CSS code from the website so I am not including them here.

I tried to combine IDs, etc but to no avail.

I am assuming you can see the HTML and CSS code from the website so I am not including them here. https://www.visualdiaryguide.com/selector.html




Angular2 - NgFor with multiple chekbox

I´m trying to create a table that has multiple checkboxes with different states (some are true, other false).

In this table i have 'Save' button to featch all elements with his state.

The code is like:

<form #form="ngForm" (ngSubmit)="save(form)">
                <table datatable [dtOptions]="dtOptions" [dtTrigger]="dtTrigger"
                  class="table table-hover table-bordered table-striped">
                  <thead>
                    <tr>
                      <th>name-placeholder</th>
                      <th>action</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr *ngFor="let card of cardsDashboard;let i=index">
                      <td></td>
                      <td>
                        <div class="form-check">
                          <label>
                            <input type="checkbox" name="checkDashboard" [(ngModel)]="card[i]"
                              (ngModelChange)="card[i].activate==true?'true':'false'" [checked]="card.activate">
                            <span class="label-text"></span>
                          </label>
                        </div>
                    </tr>
                  </tbody>
                </table>
                <div class="btn-toolbar pull-right ">
                  <div class="btn-group">
                    <button class="btn btn-primary">save</button>
                  </div>
                </div>
              </form>

The first problem: 'Save' button doesn´t update the state of elements.

Second problem: The checkboxes doesn´t show default state. Checkbox is null.

So the question is: How can i do a ngfor with checkboxes and show the state and update it?




Laravel: DataTable Multiple checkboxes

Im fetching my data in my server side and I put checkbox.

I need some clarification, do I need to put checkbox here or it will be automatically added?

Controller

$result[]  = array(
        '#'                     => '<span style="font-size: 12px; color: gray">'.$counter++.'</span>',
        'number'                => '<p>'.$value->number.'</p>',
        'vendor'                =>  '<p>'.$vendor->name .'</p>',
        'document_reference'    => '<p>'.$value->document_reference.'</p>',
        'date_needed'           => '<p>'.$value->date_needed.'</p>',
        'requesting_department' => '<p>'.$department->name.'</p>',
        'amount'                => '<p align="right">'.number_format($value->total_amount,2).'</p>',
        'status'                => '<p>'.$status.'</p>',
        'approval_status'       => '<p id="'.$value->id.'">'.$approval.'</p>',
        'created_by'            => '<p id="created_at'.$value->id.'">'.$user->name.'</p>',
        'action'                => '<a href="/requests/request-for-payment?id='.$value->id.'#view-request-for-payment-modal" class="btn btn-primary btn-sm" title="View"><i class="fa fa-eye"></i></a>',
        'checkbox'                 => '<input type="checkbox" name="checkbox[]" value="'.$value->id.'">'

In my view page I used route to call this method. In here I have now my data.

My View

var table3 = $('#get-rfp-for-approval-table').DataTable({
   'processing': true,
   'serverSide': true,
    ajax: {
        url: '/requests/request-for-payment/getRFPforApproval',
        dataSrc: ''
    },
    columns: [ 
        { data: '#' },
        { data: 'number' },
        { data: 'vendor' },
        { data: 'document_reference' },
        { data: 'date_needed' },
        { data: 'requesting_department' },
        { data: 'amount' },
        { data: 'status' },
        { data: 'created_by' },
        { data: 'approval_status' },
        { data: 'action' },
        { data: 'checkbox' },
    ],
    columnDefs: [
        {
            targets: 11,
            checkboxes: {
                selectRow: true
            }
        }
    ],
    select: {
        style: 'multi'
    },
    order: [[1,'desc']]
});

Example I have 15 data, I checked data 5 and data 14. then I submit the form.

My form

if ( $('#approved-selected-form').length > 0 ) {
    $('#approved-selected-form').submit(function(e){
        var form = this;  

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

        var formData = $(this).serialize();
        swal({
            title: "Are you sure?",
            text: "Transaction will be approved.",
            icon: "warning",
            buttons: true,
            dangerMode: true,
        })
        .then((willSave) => {
            if (willSave) {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                })
                $.ajax({
                    url: '/requests/request-for-payment/approvedTransaction',
                    type: "POST",
                    data: formData,
                    beforeSend: function() {
                        var span = document.createElement("span");
                        span.innerHTML = '<span class="loading-animation">LOADING...</span>';
                        swal({
                            content: span,
                            icon: "warning",
                            buttons: false,
                            closeOnClickOutside: false
                        });
                        $('.request-for-payment-finish').attr('disabled', 'disabled');
                    },
                    success: function(response) {
                        if (response != '') {
                            $('#get-request-for-payment-table').DataTable().destroy();
                            getRequestForPaymentTable();

                            $('#add-request-for-payment-form').trigger("reset");
                            swal("Transaction has been saved!", {
                                icon: "success",
                            });
                            setTimeout(
                                function() 
                                {
                                    window.location.href = "/requests/request-for-payment?id="+response+"#view-request-for-payment-modal";
                                }, 1500);
                        }
                    },
                    complete: function() {
                         $('.request-for-payment-finish').removeAttr('disabled');
                    }
                });
            } else {
                swal("Save Aborted");
            }
        });

        e.preventDefault();
        return false;
    })
}

NOTE: I tried to dd it in my controller it gives me this

array:1 [
  "get-rfp-for-approval-table_length" => "10"
]

Question: How can I get those values in my controller?




Using PyQt5, how can you "word wrap" a list of labelled checkboxes?

I have a number of labelled checkboxes that I want to display sequentially, in a "word wrap" fashion. But each time I add a checkbox it just makes the program wider. Any ideas on how one might achieve a word wrap effect?

from PyQt5.QtWidgets import (
  QDialog,
  QApplication,
  QGroupBox,
  QHBoxLayout,
  QVBoxLayout
)
import sys
from PyQt5 import QtWidgets


class Window(QDialog):
  def __init__(self):
    super().__init__()

    self.top = 200
    self.left = 200
    self.width = 200
    self.height = 400
    self.InitWindow()

  def InitWindow(self):
    self.setGeometry(self.left,  self.top, self.width, self.height)

    self.createLayout()
    vbox = QVBoxLayout()
    vbox.addWidget(self.groupBox)
    self.setLayout(vbox)
    self.show()

  def createLayout(self):
    self.groupBox = QGroupBox("Checkboxes:")
    hboxlayout = QHBoxLayout()

    self.A   = QtWidgets.QCheckBox("one")
    self.B   = QtWidgets.QCheckBox("two")
    self.C   = QtWidgets.QCheckBox("three")
    self.D   = QtWidgets.QCheckBox("four")
    self.E   = QtWidgets.QCheckBox("five")
    self.F   = QtWidgets.QCheckBox("six")
    self.G   = QtWidgets.QCheckBox("seven")
    self.H   = QtWidgets.QCheckBox("eight")
    self.checkboxes = [self.A, self.B, self.C, self.D, self.E, self.F, self.G, self.H]

    for checkbox in self.checkboxes:
        hboxlayout.addWidget(checkbox)
    hboxlayout.addStretch()

    self.groupBox.setLayout(hboxlayout)

if __name__ == "__main__":
  App = QApplication(sys.argv)
  window = Window()
  sys.exit(App.exec())




dimanche 21 juillet 2019

How to use Java to create checkboxes in Google Spreadsheet

I was having trouble looking for ways to create and modify checkboxes in Google Spreadsheet using Java.

I have looked through the Google API documentation and only found some Javascript APIS that could do that. The worst case is to use javax.script package to convert Javascript into java, however, that is the last thing I wish to do.




How to Check all items in a QLlistWidget?

I have a QListWidget with items that have a checkbox, I want to iterate throiugh all of them and mark them checked, I tried this:

void ScaperDialog::CheckAll(void) {
    dbg_prnt << "inside " << __func__ <<std::endl;
    QListWidget *list = parentWidget()->findChild<QListWidget *>();
    if (!list)
        std::cerr << "No QListWidget found" << std::endl;

    QList<QListWidgetItem *> items = list->findChildren<QListWidgetItem *>();
    QList<QListWidgetItem *>::iterator i;
    for (i = items.begin();i != items.end(); i++) {
        dbg_prnt << (*i)->text.ToString() << std::endl;
    }
}

but get a compiler error: error: ‘i.QList::iterator::operator*()->QListWidgetItem::text’ does not have class type dbg_prnt << (*i)->text.ToString() << std::endl; this obviously is only to print each element, to get it marked, I would do (*i)->setChecked(true); instead of printing it but I think this will give me the same error.

How do I get this rolling?




vendredi 19 juillet 2019

Lock a cell based on another cell's entry

I am building an inspection sheet in Google Sheets and have a column with check box for fail and a column with check box for pass.

How do I lock one cell when the other is checked to not allowed double checking.




Storing the value of a dynamic checkbox into the state hook

I have a form component that displays all the contacts in a stateful array as checkbox options. when the associated checkbox is checked, the contact should be passed into newGroup.groupContacts, and likewise should be removed if unchecked. What would the syntax be for including performing this action within handleCheckbox?

const CreateGroupForm = props => {

    const defaultForm = { id: null, groupName: '', groupContacts: [] }

    const [newGroup, setNewGroup] = useState(defaultForm)

    const handleInputChange = event => {
        const { name, value } = event.target 
        setNewGroup({ ...newGroup, [name]: value })
    }

    const handleCheckbox = event => {
        console.log('called')
        const {value} = event.target
        console.log(event.target)
        setNewGroup({...newGroup, groupContacts: [...newGroup.groupContacts, value] })

    }

    const handleSubmit = event => {
        event.preventDefault()

        if (!newGroup.groupName || !newGroup.groupContacts) return

        props.addGroup(newGroup)

        setNewGroup(defaultForm)

    }

    return (
        <div>
            <h2>Create a Group</h2>
            <Form onSubmit={handleSubmit}>
                <Form.Group >
                    <Form.Label>Group Name</Form.Label>
                    <Form.Control 
                        type="text" 
                        name="firstName" 
                        onChange={handleInputChange} 
                        placeholder="First Name" 
                        value={newGroup.name} 
                    />
                </Form.Group>
                <Form.Group >
                {props.contacts.map(contact => (
                    <div className="mb-3" key={contact.id}>
                        <Form.Check 
                            onChange={handleCheckbox}
                            type='checkbox'
                            label={`${contact.firstName} ${contact.lastName}`}
                            value={contact}
                        />
                    </div>
                ))}
                </Form.Group>
                <Button type="submit">Submit</Button>
                <Button>Cancel</Button>
            </Form>
        </div> 
    )
}

export default CreateGroupForm




How to insert Checkbox value to database two columns

I need one checkbox data to send to the database.

table name "status"

the column name "inline"

the column name "offline"

when the checkbox is checked it should insert "IN" into column "IN"

when the checkbox is unchecked it should insert "OUT" into column "OUT"

Thanks! enter image description here

view

                        <div class="form-group">                        
                         <div class="col-md-10">                       
            <input type="checkbox" checked data-toggle="toggle" data-on="IN" data-off="OUT">             
                    </div>
                    </div>

controller

         public function updateStatu(){
    $this->load->model('Status_Board_Model');

    $statuid = $this->input->post('statuid');
    $data = array(
        'online' => $this->input->post('online'),
        'offline' => $this->input->post('offline'),
        'comment' => $this->input->post('comment'),
    );

$this->Status_Board_Model->updateStatu( $statuid, $data);

echo json_encode(array("status" => TRUE)); }




I need a button on my home page tab that can clear all the checkboxes

I have about 15 tabs in a spreadsheet that have checkboxes in Column A.




Using :checked pseudo selector multiple times for "checkbox hack"

I am trying to use "Checkbox hack" to move and change multiple items in page's header. Only one item (div section with paragraph, links, svgs) is changed by css pseudo class :checked when input is trigerred. The logo svg, doesn't rotate after :checked .

````CSS
.menu-logo-closed{
position: absolute;
width: 29.03px;
height: 31.24px;
top: 28.45px;
right: 8%;
display: block;
transform: rotate(-183deg);
z-index: 2;
cursor: pointer;}

.section{
opacity:0;
pointer-events: none;
position: absolute;}

.section__checkbox:checked ~ .menu-logo-closed{
transform: rotate(-2.33deg);} /*:checked does nothing here */

.section__checkbox:checked ~ .section{
opacity: 1;
pointer-events: all; /*this section works*/
position: relative;} 

````HTML
<input id="header" class="section__checkbox" type="checkbox" >
        <label for="header">
        <svg viewBox="0 0 33 35" fill="none" xmlns="http://www.w3.org/2000/svg"  alt="meniu" class="menu-logo-closed">
            <path d="M1.93321 15.5657L9.20397 32.8459C9.44027 33.3771 10.4306 33.3385 10.6249 32.7906L14.9413 19.6076C15.3642 18.2852 17.7754 18.1913 18.2999 19.4768L23.6732 32.3275C23.9095 32.8587 24.8998 32.8201 25.0941 32.2722L30.913 14.4823" stroke="white" stroke-miterlimit="10"/>
            <path d="M1.66081 8.57102L8.93161 25.8523C9.16786 26.3822 10.1582 26.3436 10.3525 25.797L14.6702 12.6465C15.0932 11.3272 17.5045 11.2334 18.0288 12.5157L23.4008 25.3338C23.6371 25.8637 24.6274 25.8251 24.8218 25.2785L30.6423 7.53231" stroke="white" stroke-miterlimit="10"/>
            <path d="M1.38844 1.57633L8.62131 17.8833C8.85639 18.3833 9.84672 18.3447 10.0422 17.828L14.388 5.39759C14.8138 4.15066 17.225 4.05676 17.7465 5.26681L23.0904 17.3623C23.3255 17.8623 24.3159 17.8237 24.5114 17.307L30.3698 0.532639" stroke="white" stroke-miterlimit="10"/>
            </svg></label>
        <div  class="section">
        <p class="p-first">Lorem ipsum
        </p>strong text