mercredi 2 octobre 2019

In Coldfusion how do insert multiple checkbox values with the same name into a database?

So I am wanting to do this:

  • Start Loop to check for each checkbox in a form checked called "tags"

  • Insert into database

  • End Loop




How to add multiple checkboxes to a state

How to save multiple checkboxes to a single state and add each checkbox to its previous state

this is my states

        Operators : '',
        TypeStatus : '',
        RegistrationStatus : '',

this is my function

changeHandle = (event) => {
    this.setState({
        [event.target.name]:  event.target.value
    });
};

this is my inputs

                                            <div className="col" data-toggle="buttons">
                                                <label className={`RegisterButtons ${this.state.Operators === "MCI" ? 'RegisterButtonsActivated' : ''}`}>
                                                    <input
                                                        type="checkbox"
                                                        name="Operators"
                                                        id="MCI"
                                                        value="MCI"
                                                        onChange={this.changeHandle}
                                                        onClick={this.handleClickOperators.bind(this)}
                                                    />
                                                    همراه اول
                                                </label>
                                            </div>

                                            <div className="col" data-toggle="buttons">
                                                <label className={`RegisterButtons ${this.state.Operators === "irancell" ? 'RegisterButtonsActivated' : ''}`}>
                                                    <input
                                                        type="checkbox"
                                                        name="Operators"
                                                        id="irancell"
                                                        value="irancell"
                                                        onChange={this.changeHandle}
                                                        onClick={this.handleClickOperators.bind(this)}
                                                    />
                                                    ایرانسل
                                                </label>
                                            </div>

                                            <div className="col" data-toggle="buttons">
                                                <label className={`RegisterButtons ${this.state.Operators === "rightel" ? 'RegisterButtonsActivated' : ''}`}>
                                                    <input
                                                        type="checkbox"
                                                        name="Operators"
                                                        id="rightel"
                                                        value="rightel"
                                                        onChange={this.changeHandle}
                                                        onClick={this.handleClickOperators.bind(this)}
                                                    />
                                                    رایتل
                                                </label>
                                            </div>                       

How to save multiple checkbox to a single state and add each checkbox to its previous state




How to handle multiple checkboxes

I am working on a project in which I need to filter results on the basis of checked items. I want to select one or more than one item from different categories and also want to consol.log(...) selected items by clicking on the Apply button to know which items have been selected. Here is the screenshot of screen

enter image description here

Here is my code

const { allergens, cuisine, deliveries, dietagges, environments, services } = this.state.data;

      <View style={styles.sliderContainer}>
        {allergens !== null && allergens !== undefined ? (
          <View>
            <Text style={styles.sliderLabel}>Allergens:</Text>
            {allergens.map((item, index) => {
              return (
                <View style={styles.checkBoxContainer} key={index}>
                  <Text style=>
                    {item && item[0]}{" "}
                    <Text style=>
                      ({item && item[1]})
                    </Text>
                  </Text>
                  <CheckBox
                        checked={false}
                        onPress={() => this.handleValueChange()}
                  />
                </View>
              );
            })}
          </View>
        ) : null}
      </View>
<View style={styles.sliderContainer}>
            {environments !== null && environments !== undefined ? (
              <View>
                <Text style={styles.sliderLabel}>Environments:</Text>
                {environments.map((item, index) => {
                  return (
                    <View style={styles.checkBoxContainer} key={index}>
                      <Text style=>
                        {item && item[0]}{" "}
                        <Text style=>
                          ({item && item[1]})
                        </Text>
                      </Text>
                      <CheckBox
                        checked={false}
                        onPress={() => this.handleValueChange()}
                      />
                    </View>
                  );
                })}
              </View>
            ) : null}
          </View>
          <View style={styles.sliderContainer}>
            {cuisine !== null && cuisine !== undefined ? (
              <View>
                <Text style={styles.sliderLabel}>Cuisine:</Text>
                {cuisine.map((item, index) => {
                  return (
                    <View style={styles.checkBoxContainer} key={index}>
                      <Text style=>
                        {item && item[0]}{" "}
                        <Text style=>
                          ({item && item[1]})
                        </Text>
                      </Text>
                      <CheckBox
                        checked={false}
                        onPress={() => this.handleValueChange()}
                      />
                    </View>
                  );
                })}
              </View>
            ) : null}
          </View>

And here is the data coming from API

"cuisine": [
                    [
                        "Middle Eastern",
                        4
                    ],
                    [
                        "Western",
                        4
                    ],
                    [
                        "Pasta Dishes",
                        2
                    ],
                    [
                        "Salad",
                        2
                    ],
                    [
                        "Mexican",
                        1
                    ],
                    [
                        "Soup",
                        1
                    ],
                    [
                        "snacks",
                        1
                    ]
                ],
                "allergens": [
                    [
                        "Halal",
                        14
                    ]
                ],
                "environments": [
                    [
                        "Mexican",
                        15
                    ]
                ],

How to select or unselect items without affecting others? Thanks in advance.




mardi 1 octobre 2019

keep checkbox checked after POST

I have an array of checkbox and after POST the check mark disappears. I've tried different solutions but doesn't seem to work. I'm not sure if it is due to the complicated values of the checkbox. The values have special characters, I'm not sure if it matters. Please see my code below.

<form action="<?php echo $_SERVER['PHP_SELF']; ?>"  method="post">
<?php 
        if (isset($_POST["check"]))
              $brand = $_POST["check"];
    else 
      $check="";
 ?>

     <input type="checkbox" name="check[]" value="request LIKE '%&lt;text1&gt;%'" <?php if(isset($_POST["check"][0]))
      { if($_POST["check"][0]=="request LIKE '%&lt;text1&gt;%'"){ echo 'checked="checked"';} } ?>><label>Option 1</label>

     <input type="checkbox" name="check[]" value="request LIKE '%&lt;text2&gt;%'" <?php if(isset($_POST["check"][0]))
      { if($_POST["check"][0]=="request LIKE '%&lt;text2&gt;%'"){ echo 'checked="checked"';} } ?>><label>Option 2</label>

  </form>

This doesn't work as well:

<input type="checkbox" name="check[]" value="request LIKE '%&lt;text1&gt;%'"<?=(in_array("request LIKE '%&lt;text1&gt;%'", $check) ? ' checked="checked"' : '') ?> />



Click a checkbox, and start a background timer to "uncheck" the next two row checkbox automatically afterwards

When I click a checkbox, then run a background timer, after that will auto click the next two row checkbox. Please help, I can't fix this long time already...

I refer to this example: https://support.google.com/docs/thread/3199678?hl=en

Here is my Google sheet, I was set it to edit mode, u can edit the code in "Script editor": https://docs.google.com/spreadsheets/d/1pSzk8yl1HNoi_njPnYLQxwK34KY_JWJST5Yz8k_CRIU/edit?usp=sharing

Sorry bad English and poor on coding... Please help me

Thanks!




Binding with v-model in custom checkbox component doesn't work

I'm trying to build a custom checkbox component with options that are generated with a v-for loop from an array with options and values. How can I bind the v-model correctly to the checkbox component so that it's correctly updated?

The problem now is that the model only updates to the latest checkbox that is checked and does not give an array with all checked options.

Vue.component('ui-checkbox', {
         props: {   
    label: {
      type: String,
      required: true,
    },
    index: {
      type: Number
    },
    inputValue: {
      type: String
    }
  },
  methods: {
    onChange(e) {
      this.$emit('input', e.target.value);
    },
  },
        template: `<div>
    <input 
      :id="index"
      type="checkbox"
      :value="inputValue"
      @change="onChange" />
    <label :for="index">
      
    </label>
  </div>`,
})

new Vue({
  el: "#app",
  data: {
    checkOptions: [
      {
        label: 'Option 1',
        value: 'value of option 1',
      },
      {
        label: 'Option 2',
        value: 'value of option 2',
      },
      {
        label: 'Option 3',
        value: 'value of option 3',
      },
      {
        label: 'Option 4',
        value: 'value of option 4',
      },
    ],
    myCheckBoxModel: []
  },
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
   <span>checked Checkboxes:  </span>
   <ui-checkbox
     v-for="(option, index) in checkOptions"
     v-model="myCheckBoxModel"
     :key="index"
     :index="index"
     :input-value="option.value"
     :label="option.label" />    
</div>



i want to manage the menu section on the user role on checking the check box in core php

In my project 3 roles are their admin,staff and security i want to give full menu access to admin.how can I do.I want to build dynamic menu access for user role.each user role have different user role.giving the permission about menu.