mercredi 3 novembre 2021

Formstack API - Field with multiple checkbox values as array

I create new submission for the specified form. I read documentation on https://developers.formstack.com/reference/form-id-submission-post I tested a lot of methods but nothing work. Only 'string' works fine (one value). I don't know where is error in my array.

// one value as string
'body' => json_encode([
    // x - is a field id
    'field_x' => 'option-1',
]),

// solution 1
'body' => json_encode([
    // x - is a field id
    'field_x' => [
        '1' => 'option-1',
        '2' => 'option-2'
    ],
]),

// solution 2
'body' => json_encode([
    // x - is a field id
    'field_x' => [
        'option-1',
        'option-2'
    ],
]),

// solution 3
'body' => json_encode([
    // x - is a field id
    'field_x' => [
        1 => 'option-1',
        2 => 'option-2'
    ],
]),



How to save q checkbox to show and habilit button in another page

How to save a checkbox to show and habilit button in another page.

For example, one page i can choose un/checked checkbox, and another show resultado Green and habilit this button.

I need help!




CheckboxTree, if I activate them (checked), the tree also closes

Problem is with checkboxes, if I activate them (checked), the tree also closes. But I want it to stay open until I have selected all checkboxes. So when you click in the checkbox, it gets closed.

$( 'input[type="checkbox"]' ).change( function ( e )

    {

        var checked = $( this ).prop( "checked" ),

            container = $( this ).parent(),

            siblings = container.siblings();



        container.find( 'input[type="checkbox"]' ).prop( {

            indeterminate: false,

            checked: checked

        } );



        function checkSiblings( el )

        {

            var parent = el.parent().parent(),

                all = true;



            el.siblings().each( function ()

            {

                return all = ( $( this ).children( 'input[type="checkbox"]' ).prop( "checked" ) === checked );

            } );



            if ( all && checked )

            {

                parent.children( 'input[type="checkbox"]' ).prop( {

                    indeterminate: false,

                    checked: checked



                } );



                checkSiblings( parent );



            } else if ( all && !checked )

            {

                parent.children( 'input[type="checkbox"]' ).prop( "checked", checked );

                parent.children( 'input[type="checkbox"]' ).prop( "indeterminate", ( parent.find( 'input[type="checkbox"]:checked' ).lenght > 0 ) );

                checkSiblings( parent );

            } else

            {

                el.parents( "li" ).children( 'input[type="checkbox"]' ).prop( {

                    indeterminate: true,

                    checked: false

                } );



            }

        }



        checkSiblings( container );

    } );



    $( document ).ready( function ()

    {

        $( "#tree .open" ).click( function ( e )

        {

            e.stopPropagation();

            $( this ).toggleClass( "open closed" );

        } );

    } );
#tree {

        width: auto;

        height: 350px;

        line-height: 20px;

        border: 1px solid #ccc;

        padding: 10px;

        margin: 10px;

        overflow: scroll;

        overflow-x: hidden;

    }

#tree .open > ul {

            display: none;

        }

#tree .open, #tree .closed {

            cursor: pointer;

        }

#tree .open::before {

                content: "\002B";

                font-size: 25px;

                display: inline-block;

                margin-left: 2px;

                width: 20px;

            }

#tree .closed::before {

                content: "\2212";

                font-size: 25px;

                display: inline-block;

                margin-left: 2px;

                width: 20px;

            }
<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8" />

    <link href="style.css" rel="stylesheet" />

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

    <title>checkboxTree</title>

</head>

<body>

<!--CheckboxTree-->

<div class="col">

    <ul id="tree" style="list-style-type: none;">

        <li class="open">

            <input type="checkbox" name="tall" id="tall">

            <label for="tall">Item 1</label>



            <ul style="list-style-type: none;">

                <li>

                    <input type="checkbox" name="tall-1" id="tall-1">

                    <label for="tall-1">Item 1.1</label>

                </li>

                <li class="open">

                    <input type="checkbox" name="tall-2" id="tall-2">

                    <label for="tall-2">Item 1.1.1</label>



                    <ul style="list-style-type: none;">

                        <li>

                            <input type="checkbox" name="tall-2-1" id="tall-2-1">

                            <label for="tall-2-1">Item 1.1.2</label>

                        </li>

                        <li>

                            <input type="checkbox" name="tall-2-2" id="tall-2-2">

                            <label for="tall-2-2">Item 1.1.3</label>

                        </li>

                    </ul>

                </li>

                <li>

                    <input type="checkbox" name="tall-3" id="tall-3">

                    <label for="tall-3">Item 1.2</label>

                </li>

            </ul>

        </li>

        <li class="open">

            <input type="checkbox" name="short" id="short">

            <label for="short">Item 2</label>



            <ul style="list-style-type: none;">

                <li>

                    <input type="checkbox" name="short-1" id="short-1 " checked>

                    <label for="short-1">Item 2.1</label>

                </li>

                <li>

                    <input type="checkbox" name="short-2" id="short-2" disabled>

                    <label for="short-2">Item 2.2</label>

                </li>

                <li>

                    <input type="checkbox" name="short-3" id="short-3" checked disabled>

                    <label for="short-3">Item 2.3</label>

                </li>

                <li>

                    <input type="checkbox" name="short-3" id="short-3">

                    <label for="short-3">Item 2.3</label>

                </li>

                <li>

                    <input type="checkbox" name="short-3" id="short-3">

                    <label for="short-3">Item 2.4</label>

                </li>

                <li>

                    <input type="checkbox" name="short-3" id="short-3">

                    <label for="short-3">Item 2.5</label>

                </li>

            </ul>

        </li>

    </ul>

</div>

<!--CheckboxTree end-->

</body>

</html>

I have no way of activating the checkboxes. The tree closes when you click on the checkbox. Example when clicking on Item 1.1.3 or Item 1.2 or Item 1.1 Tree closes. The tree has to stay open and when I click plus or minus it should close.




How to activate a button when selecting several mat-checkbox and deactivate it only when nothing is selected? (Angular material)

I'm making a table using Angular Material. Inside the table I have data, which is added from a DB that I have created in JAVA. The checkboxes are created depending on the number of rows (data) that are in the DB. The idea is that the button to send this data to another table MUST BE disabled and it MUST ONLY BE ENABLED when there is at least 1 active checkbox, if there is no active checkbox the button must be disabled.

The problem is that when I deselect 1 checkbox the button is disabled, regardless of whether the other checkboxes are active.

HTML

<button mat-raised-button [disabled]="buttonDisable" (click)="procesarClic()">Enviar</button>

<ng-container matColumnDef="seleccionVarios">
              <mat-header-cell *matHeaderCellDef><label class="tituloTabla-verdoso text-center"> CHECKBOX </label></mat-header-cell>
              <mat-cell *matCellDef="let element">
                <mat-checkbox #checkbox (click)="$event.stopPropagation()"
                                        (change)="$event ? selection.toggle(element) : null; changeCheck($event)"
                                        [checked]="selection.isSelected(element)">
               </mat-checkbox>
             </mat-cell>
</ng-container>

TypeScript

export class PaginaPrincipal implements OnInit {
    buttonDisable: boolean = true;

changeCheck(event){
    this.buttonDisable = !event.checked;
  }




How to send multi checkbox input value in php reusable forms?

I am using the "reusableforms.com" PHP form script. The form is working well. But I got an error on multi-input checkbox values.

How can I get the multi-input checkbox values?

HTML Code:

<div class="form-box">
    <label>Choose which of the following are most important to you:</label>
    <div class="multi-select">
        <div class="custom-select">
            <input type="checkbox" id="hight-rating" value="High Rating" name="important" hidden>
            <label for="hight-rating">High Rating</label>
        </div>
        <div class="custom-select">
            <input type="checkbox" id="mobile-phone-app" value="Mobile phone app" name="important" hidden>
            <label for="mobile-phone-app">Mobile phone app</label>
        </div>
        <div class="custom-select">
            <input type="checkbox" id="vendor-management" value="Vendor management" name="important" hidden>
            <label for="vendor-management">Vendor management</label>
        </div>
    </div>
</div> 

handler.php

<?php
    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    error_reporting(E_ALL);

    require_once './vendor/autoload.php';
    
    use FormGuide\Handlx\FormHandler;    
    
    $pp = new FormHandler(); 
    
    $validator = $pp->getValidator();
    $validator->fields(['name','email', 'phone', 'address', 'property', 'following', 'units', 'date'])->areRequired()->maxLength(50);
    $validator->field('important[]')->maxLength(5000);
    $validator->field('email')->isEmail();
    
    
    $pp->sendEmailTo('xxx@gmail.com'); // ← Your email here
    
    echo $pp->process($_POST);
?>

Thank you.




mardi 2 novembre 2021

How to get the items from list according to id in flutter

Requirement:

I created a list of days using CheckboxlistTile, and i want when i check any checkbox a button will display, and onclick on button a dialogue will display where user can add time in textfield, and then on click on submit button of dialogue that textfield time input will convert into a tag and will display below the checkbox.

here my screen look like before check the checkbox

enter image description here

initially i set monday checkbox checked.

so when i click on add button (which in at the right of checkbox), this dialogue will display

enter image description here

and when i enter the values and after clicking on submit button, tag will look like this

enter image description here

Problem:

Problem is, when i check the tuesday or any other checkbox this tag is displaying in its list, wherease i have not selected time for tuesday or any checkbox, i guess the problem is in list which i'm passing to create tags _timingTagListForToken

enter image description here

here is the code:

Days list class

class CheckBoxListTileModelForToken {
  int id;
  String title;
  bool isCheck;

  CheckBoxListTileModelForToken({required this.id,required this.title, required this.isCheck});

  static List<CheckBoxListTileModelForToken> getUsers() {
    return <CheckBoxListTileModelForToken>[
    CheckBoxListTileModelForToken(id:1,title: "Monday", isCheck: true,),
    CheckBoxListTileModelForToken(id:2,title: "Tuesday", isCheck: false),
    CheckBoxListTileModelForToken(id:3,title: "Wednesday", isCheck: false),
    CheckBoxListTileModelForToken(id:4,title: "Thursday", isCheck: false),
    CheckBoxListTileModelForToken(id:5,title: "Friday", isCheck: false),
    CheckBoxListTileModelForToken(id:6,title: "Saturday", isCheck: false),
    CheckBoxListTileModelForToken(id:7,title: "Sunday", isCheck: false),
    ];
  }
}

Code where i'm display the Checkboxes

customExpansionTile(context, "Token Distribution Time", 
          true,
            Icon(Icons.timer, color: HexColor("#5344ed")), 
            <Widget>[
            Container(
                child: Row(
              children: [
                Expanded(
                    child: SizedBox(
                        height: MediaQuery.of(context).size.height * 0.45,
                        child: ListTile(
                          title: ListView.builder(
                          itemCount: checkBoxListTileModelForToken.length,
                          itemBuilder: (BuildContext context, int index) {
                          return new Card(
                            child: new Container(
                              padding: new EdgeInsets.all(10.0),
                              child: Column(
                                children: <Widget>[
                                  new CheckboxListTile(
                                      controlAffinity:ListTileControlAffinity.leading,
                                      activeColor: HexColor("#5344ed"),
                                      dense: true,
                                      title: new Text(
                                        checkBoxListTileModelForToken[index].title,
                                        style: TextStyle(
                                            fontSize: 14,
                                            fontWeight: FontWeight.w600,
                                            letterSpacing: 0.5),
                                      ),
                                      value: checkBoxListTileModelForToken[index].isCheck? true:false,
                                      secondary:  Container(
                                      alignment:Alignment.centerRight,
                                      height: MediaQuery.of(context).size.height*0.9,
                                      width: MediaQuery.of(context).size.width *0.2,
                                      child:checkBoxListTileModelForToken[index].isCheck ==true?
                                          IconButton(
                                            tooltip:"Pick Time",
                                            onPressed: () {
                                              _tokenTimeDialogue(
                                                  checkBoxListTileModelForToken[index].id);
                                            },
                                            icon: Icon(Icons.add,color: HexColor("#5344ed"),)
                                          )
                                              : null),
                                    onChanged: (bool? val) {
                                 itemChangeforToken(val!, index);
                                    }),
                                    SizedBox10(),
                                    Wrap(
                                      direction:Axis.horizontal,
                                      children:[
                                        Container(
                                      child:checkBoxListTileModelForToken[index].isCheck? Tags(
                                        itemCount:_timingTagListForToken.length,
                                        itemBuilder: (int index){          
                                        return  ItemTags(
                                              key: Key(index.toString()),
                                              activeColor:HexColor("#5344ed"),
                                              index: index, 
                                              title:_timingTagListForToken[index],
                                              textStyle: TextStyle( fontSize: 14, ),
                                              combine: ItemTagsCombine.withTextBefore,
                                              
                                              removeButton: ItemTagsRemoveButton(
                                                backgroundColor:HexColor("#5344ed"),
                                                onRemoved: (){  
                                                    setState(() {
                                                        _timingTagListForToken.removeAt(index);
                                                    });
                                                    return true;
                                                },
                                              ),
                                              onPressed: (item) => print(item),
                                              onLongPressed: (item) => print(item),
                                        );
                                      },):Padding(
                                        padding: const EdgeInsets.only(left: 70),
                                        child:
                                            Row(crossAxisAlignment: CrossAxisAlignment.center, children: []))
                                                                ),
                                      ])]),
                          ),
                        );
                      }),
                  
                      ))),



 itemChangeforToken(bool val, int index) {
  setState(() {
    //id=checkBoxListTileModelForToken[index].id;
      //print("id onchange "+ id.toString());
    checkBoxListTileModelForToken[index].isCheck = val;

   
    
  });
  
}


Dialogue code


_tokenTimeDialogue(dynamic id) {
    AlertDialog alert = AlertDialog(
        scrollable: true,
        insetPadding: EdgeInsets.symmetric(vertical: 50),
        title: Text("Add timing of the day",
          style: TextStyle(fontWeight: FontWeight.bold, color: HexColor("#5344ed"))),
        content: Container(
          child: SingleChildScrollView(
          scrollDirection: Axis.vertical,
          child: Column(children: <Widget>[
            textfieldforTimeDialogue(
              context,
              () async {
                    TimeOfDay? pickedTime = await showTimePicker(
                      initialTime: TimeOfDay.now(),
                      context: context,
                      builder:(context, child) {
                            return Theme(
                              data: Theme.of(context).copyWith(
                                colorScheme: ColorScheme.light(
                                  primary: HexColor(
                                      "#6610f2"), // header background color
                                  onPrimary: Colors.black, // header text color
                                  onSurface: Colors.black, // body text color
                                ),
                                textButtonTheme: TextButtonThemeData(
                                  style: TextButton.styleFrom(
                                    primary: HexColor(
                                        "#6610f2"), // button text color
                                  ),
                                ),
                              ),
                              child: child!,
                            );
                          },
                    );
                    if (pickedTime != null) {
                      setState(() {
                        fromTimeForToken.text = pickedTime.format(context);
                      });
                    } else {
                      print("Time is not selected");
                    }
                  },
                  Icons.timer_off,
                  fromTimeForToken,
                  "From",
                  "From",
            ),
            
            SizedBox20(),
            textfieldforTimeDialogue(
              context,
              () async {
                FocusScope.of(context).unfocus();
                    TimeOfDay? pickedTime = await showTimePicker(
                      initialTime: TimeOfDay.now(),
                      context: context,
                       builder:(context, child) {
                            return Theme(
                              data: Theme.of(context).copyWith(
                                colorScheme: ColorScheme.light(
                                  primary: HexColor(
                                      "#6610f2"), // header background color
                                  onPrimary: Colors.black, // header text color
                                  onSurface: Colors.black, // body text color
                                ),
                                textButtonTheme: TextButtonThemeData(
                                  style: TextButton.styleFrom(
                                    primary: HexColor(
                                        "#6610f2"), // button text color
                                  ),
                                ),
                              ),
                              child: child!,
                            );
                          },
                    );
                    if (pickedTime != null) {
                      setState(() {
                        toTimeForToken.text = pickedTime.format(context);
                      });
                    } else {
                      print("Time is not selected");
                    }
                  },
                  Icons.timer_off,
                  toTimeForToken,
                  "To",
                  "To",
            ),
          ]),
        )),
        actions: [
          TextButton(
            
            onPressed: () {
            setState(() {
            fromTimeForToken.text="";
            toTimeForToken.text="";
            });
              Navigator.pop(context);
            },
            child: Text(
              "Submit",
              style: TextStyle(
                  fontWeight: FontWeight.bold,
                  color: HexColor("#5344ed"),
                  fontSize: 20),
            ),
          )
        ]);
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return alert;
      },
    );
  }


please help where i'm doing wrong, how i can do this?




How to check svg checkbox tree using a console in Dev Tools?

I'd like to write a command to check a checkbox, however, i got stuck with writing appropriate querryselector for svg object (checkbox) and choosing a first child in a tree. Another trick - here is a checkbox tree.site with a checkbox

sample is below

<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="rct-icon rct-icon-uncheck" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" xpath="1"><path d="M19 5v14H5V5h14m0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2z"></path></svg>

here is a link to website: https://demoqa.com/checkbox