jeudi 31 octobre 2019

Wicket Checkboxes in datatable with pagination

I am using Datatables jquery table in Wicket. In java code, I am preparing with RepeatingViews the table thead and tbody HTML tags and then I am calling DataTable javascript constructor to create table with paging, sorting and so on.

I want to add the checkbox column to the table. Main checkbox in thead (title of the table) should switch all rows checkboxes in the table.

The problem is pagination, when I click on main checkbox, some checkboxes are not existing in the DOM, because they are on different table pages. Wicket throws me this errors:

ERROR: Wicket.Ajax.Call.processComponent: Component with id [[id187]] was not found while trying to perform markup update. Make sure you called component.setOutputMarkupId(true) on the component whose markup you are trying to update.
ERROR: Cannot bind a listener for event "change" on element "checkbox76" because the element is not in the DOM

The code which is bound on main checkbox is:

    @Override
    public void update(AjaxRequestTarget target, boolean state) {
        for (int i = 0; i < rowsCheckboxes.size(); i++) {
            CustomCheckbox checkbox = rowsCheckboxes.get(i);
            checkbox.setState(state);
            target.add(checkbox);
        }
    }

CustomCheckbox looks like:

public abstract class CustomCheckbox extends Panel {
    private static final long serialVersionUID = 1L;

    private boolean state;
    public CheckBox checkbox;

    public CustomCheckbox(String id) {
        super(id);

        checkbox = new CheckBox("checkbox", new PropertyModel<>(this, "state"));
        checkbox.add(new OnChangeAjaxBehavior() {
            private static final long serialVersionUID = 1L;

            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                update(target, state);
            }
        });

        setOutputMarkupId(true);
        add(checkbox);
    }

    public abstract void update(AjaxRequestTarget target, boolean state);

    public void setState(boolean state) {
        this.state = state;
    }

}

HTML of this CustomCheckbox:

<wicket:panel>
    <span class="custom-checkbox">
        <input wicket:id="checkbox" type="checkbox">
        <label for="select"></label>
    </span>
</wicket:panel>

How can I approach this problem? I would like to switch with main checkbox all checkboxes located on current table page which is shown to user right now.

I have tried this, but without success:

setOutputMarkupId(true);
setOutputMarkupPlaceholderTag(true);

These checkboxes I am using for clone or delete the table items.

Thanks for any answer.




Laravel checkbox not checking just because changing layout

Working on Laravel Project, I have two layouts.

  1. app.blade.php see on my git repo
  2. old_app.blade.php see on my git repo

When I use @extends('layouts.old_app') in my blade file, its working fine like this:
old_app.blade.php

But when I use @extends('layouts.app') in my blade file, the checkbox is gone:
app.blade.php

This is my Controller:

public function create()
{
    $permission = Permission::get();
    return view('roles.create', compact('permission'));
}

This is my View

<div class="form-group">
    @foreach($permission as $value)
       <label>
          <input type="checkbox" class="name" value="" name="permission[]">
       </label>
    @endforeach
</div>

Sorry for my bad english, I would to say thanks for anyone who can help me.




How to check the state (enabled/disabled) of a checkbox in python (tkinter)

I have a program I am writing in Python and I'm having trouble with checking the state of a checkbox. I do NOT want to check whether it is checked or unchecked, but rather if it is disabled or enabled.

As a background, I have numerous checkboxes which i want displayed on screen, but based on the users selection within an option menu i want certain checkboxes to enable or disable. Ok easy enough. Now to the problem. I also have two buttons radiobuttons called "select ALL" and "select NONE"

My issue is that when i choose select ALL or select NONE it enables or disables ALL checkboxes, even those which are disabled.

I don't want to post the whole code because it is quite long so I will post a snippet of each section for reference, but would really appreciate any help in this. (NOTE: I hardcoded the state of the checkbuttons in the code below for testing/ease, but they will be enabled/disabled through a command from the option menu as mentioned above. I also only included two checkbuttons so that the code is not so long)

I have done a lot of searching but can only find info on how to enable/disable a checkbutton and how to check whether it is checked or not but not how to check whether or not it is disabled.

def select_all():
        var1.set(1), var2.set(1), var3.set(1), var4.set(1), var5.set(1), var6.set(1), var7.set(1), var8.set(1), var9.set(
        1), var10.set(1)


def select_none():

    var1.set(0), var2.set(0), var3.set(0), var4.set(0), var5.set(0), var6.set(0), var7.set(0), var8.set(0), var9.set(
        0), var10.set(0)
r = tk.Tk()
r.title('Title')

checkFrame = Frame(r)
checkFrame.pack()

var1 = IntVar()
C1 = Checkbutton(checkFrame, text='Option 1', state='disable', variable=var1)
C1.grid(row=0, column=0, sticky=W, pady=4, padx=15)
var2 = IntVar()
C2 = Checkbutton(checkFrame, text='Option 2', state='normal', variable=var2)
C2.grid(row=0, column=1, sticky=E, pady=4, padx=15)

selectAllCheck = IntVar()
Radiobutton(selectAllFrame, text='Select ALL', indicatoron=0, width=15, variable=selectAllCheck, value=1,
            command=select_all).grid(row=0, column=0, sticky=W, pady=10)
Radiobutton(selectAllFrame, text='Select NONE', indicatoron=0, width=15, variable=selectAllCheck, value=2,
            command=select_none).grid(row=0, column=1, sticky=E, pady=10)



How to avoid selected checkboxes not to affect other areas of the checkboxs and store state in new array?

I have this component which requires user to select programs (all and/or single). After selecting a program, user can choose to add more programs by clicking on "Add another program" button at the end. Whatever I select on first box is displaying with the proper programs that I selected. However, when I go to second box and select program again, whatever I select on the second box is also updating the first box.

Can someone please help? I got most of the code written down:

this.state = {
  programs: [],
  programCheckedList: [],
  programSelected: false
};

handleSelectProgram = e => {
  const { checked } = e.target;
  let collection = [];
  if (checked) {
    collection = this.handleGetAllPrograms();
  }
  this.setState({
    programCheckedList: collection,
    programSelected: checked
  });
};

handleGetAllPrograms = () => {
  const { programs } = this.state;
  const collection = [];
  for (const prog of programs) {
    collection.push(prog.programId);
  }
  return collection;
};

handleProgramCheckbox = e => {
  const { value, checked } = e.target;
  if (checked) {
    const collection = this.handleGetAllPrograms();
    this.setState(prevState => ({
      programCheckedList: [...prevState.programCheckedList, value * 1],
      programSelected: collection.length === prevState.programCheckedList.length + 1
    }));
  } else {
    this.setState(prevState => ({
      programCheckedList: prevState.programCheckedList.filter(item => item != value),
      programSelected: false
    }));
  }
};

render() {
  return (
    <label className="container select-all">
      <input
        type="checkbox"
        id="selectAllPrograms"
        checked={programSelected}
        onClick={this.handleSelectProgram}
      />
      <span class="checkmark" />
      <p>
        <strong>
          All programs
        </strong>
      </p>
    </label>
    <hr/>
    {_.map(programs, (program, pos) => {
      const { programId, programDescription, programName } = program;
      return (
        <div className="programs-list" key={pos}>
          <label className="container">
            <input
              type="checkbox"
              id={`program_${programId}`}
              name={`${programDescription} (${programName})`}
              value={programId}
              checked={programCheckedList.includes(programId)}
              onChange={this.handleProgramCheckbox}
            />
            <span class="checkmark" />
            <p>{programName}</p>
          </label>
        </div>
      );
    })}
  )
}

Desired output that I am looking for:

Box 1: program 1 selected

Box 2: program 1 and 2 selected

Box 3: all programs selected




Unable to change font awesome icon color when checked - Check box

the first one works but I am unable to change the color of the second (.fa ). I am able to change the font color while not active.

#pgggo-sort-filter ul li label input[type="checkbox"]:checked ~ .icon-box{
  background: green;
  /* padding: 10px; */
}

#pgggo-sort-filter ul li label input[type="checkbox"]:checked ~ .fa{
  color: yellow;
}

my html

 <div id="pgggo-sort-filter" class="pgggo-sort-filter">
              <ul>
                <li>
                   <label>
                     <input type="checkbox" name="">
                     <div class="icon-box">
                       <i class="fa fa-arrow-circle-o-down" area-hidden="true"></i>
                     </div>
                   </label>
                   <label>
                     <input type="checkbox" name="">
                     <div class="icon-box">
                       <i class="fa fa-arrow-circle-o-up" area-hidden="true"></i>
                     </div>
                   </label>
                </li>
              </ul>
              <a class="button primary" href="#">Sort
              </a>
            </div>



Disable button if checkboxes are unchecked - across groups - in an ajax response

This is an adaptation of Disable button if all checkboxes are unchecked and enable it if at least one is checked

On the above post they are disabling a button unless at least 1 checkbox is checked.

In my situation, I have 2 sets of checkboxes:

<div class="clone-ctp__filters">
    <input type="checkbox"> <label>Foo 1</label>
    <input type="checkbox"> <label>Bar 2</label>
    <input type="checkbox"> <label>Baz 3</label>
</div>

<div class="clone-ctp__users">
    <input type="checkbox"> <label>Foo 5</label>
    <input type="checkbox"> <label>Bar 6</label>
    <input type="checkbox"> <label>Baz 7</label>
</div>

Followed by a submit button

<button>Continue</button>

What I'm trying to do is disable the 'Continue' button unless at least 1 checkbox is checked in both groups (.clone-ctp__filters and .clone-ctp__users).

The checkboxes themselves have been rendered via an ajax response, i.e. the HTML is written to .clone-ctp__filters and .clone-ctp__users as the response from 2 separate ajax requests to get the appropriate data.

I've used ajaxStop to make sure the code to disable/enable the button fires after the ajax response has completed:

$(document).ajaxStop(function() {
    var checkBoxes = $('input[type="checkbox"]');
    checkBoxes.change(function () {
        $('button').prop('disabled', checkBoxes.filter(':checked').length < 1);
    });
    $('input[type="checkbox"]').change();
});

This has the same effect as the linked post. It will disable the button unless at least 1 checkbox is checked. But it has no bearing on which set of checkboxes that's from.

My solution to this was to duplicate the code, e.g.

var checkBoxes = $('.clone-ctp__filters input[type="checkbox"]');

Then when that completes repeat it with

var checkBoxes = $('.clone-ctp__users input[type="checkbox"]');

This goes against the principles of DRY. Is there a more elegant way to write this?

jquery 3.2.1




On Changing page(pagination) in asp.net web app the checkbox not working

In asp.net project I am using javascript. In a page there are lots of datas. So, I am doing pagination for my convenience. After changing to next page I can't check the checkbox.




mercredi 30 octobre 2019

Select one checkbox disable remaining checkboxes based on condition

I'm facing one problem There is three questions and each question different options is there. when open mat-expansion pane l (positive) means question 1 and i select option 1 automatically second question and third question first option selected...... please help me...

in above problem questions means -> mat-accordion options means -> mat-checkbox




Android: Generate n number of checkboxes and make 2 of them selectable

I need to make n number of checkboxes and make two of them selectable. The user can select one, then another. If the user selects a third, the second checkbox is un checked and so on. The user may also uncheck a checked box to make another choice.

I am pretty lost on what to do.

My current code: Im adding the checkboxes dynamically to a linear layout called checkBoxContainer here

 for (int i = 0; i < count; i++) {
            MaterialCheckBox checkBox = new MaterialCheckBox(context);
            checkBox.setText(String.format(Locale.getDefault(),"Checkbox %d", i));
            checkBox.setId(i);
            checkBox.setTag("Answer id : " + i);
            checkBox.setOnClickListener(this);
            checkBoxContainer.addView(checkBox);
 }

Im stuck with this part

 @Override
    public void onClick(View view) {
        int id = view.getId();
        MaterialCheckBox CheckedCheckBox = findViewById(id);
        CheckedCheckBox.setChecked(true);
        checkCount+=1;
        mLog.i(TAG,"count : + "+checkCount);
        if(checkCount<2){
        checkedIds.add(id);
        }else{
            MaterialCheckBox LastCheckedCheckBox = findViewById(id);
            LastCheckedCheckBox.setChecked(false);
            //checkedIds.remove(id)
        }


    }

You may ignore what I've written after CheckedCheckBox.setChecked(true); its just there to show that I have tired. It's nowhere near complete. Can someone give me and idea how to do this.




How To Visible DataGridView Columns Using Checkbox's C#

How Can I Visible and Invisible Columns in DataGridView By Checked and Unchecked Check box's using C#.

enter image description here




Change value attribute of checkbox base on checked value with knockout JS

I'm trying to a checkbox and send the value YES or NO in my submitted form, base in if is checked or no but the value is not updated here is my code:

self.checkbox = ko.observable("No");
    self.is_checked = ko.computed({
        read: function (data) {
            return false;
        },
        write: function (data, event) {  self.is_checked() ? self.checkbox('Yes'):  self.checkbox('No');}

    });

data-bind="checked: is_checked, checkedValue:checkbox"

any clues or links to read, please.




Vue-MultiSelect Checkbox binding

The data properties of the multi-select component does not update on change. Check-boxes doesn't update on the front-end.

Expected Behavior : The check-boxes should get ticked, when clicked.

Can someone help me ?

Link to code : https://jsfiddle.net/bzqd19nt/3/

  <multiselect 
    select-Label=""
    selected-Label=""
    deselect-Label=""
    v-model="value" 
    :options="options"
    :multiple="true"
    track-by="library"
    :custom-label="customLabel"
    :close-on-select="false"
    @select=onSelect($event)
    @remove=onRemove($event)
    >
    <span class="checkbox-label" slot="option" slot-scope="scope" @click.self="select(scope.option)">
    
      <input class="test" type="checkbox" v-model="scope.option.checked" @focus.prevent/>

    </span>
  </multiselect>
  <pre></pre>
</div>
    components: {
    Multiselect: window.VueMultiselect.default
    },
    data: {
    value: [],
    options: [
        {   language: 'JavaScript', library: 'Vue.js', checked: false },
      { language: 'JavaScript', library: 'Vue-Multiselect', checked: false },
      { language: 'JavaScript', library: 'Vuelidate', checked: false }
    ]
    },
  methods: {
    customLabel (option) {
      return `${option.library} - ${option.language}`
    },
    onSelect (option) {
        console.log("Added");
      option.checked = true;
      console.log(option.library + "  Clicked!! " + option.checked);
    },

    onRemove (option) {
        console.log("Removed");
      option.checked = false;
      console.log(option.library + "  Removed!! " + option.checked);
    }
  }
}).$mount('#app')



How to get the values of a row checked in a Listview VB

i got a listview that is databound to an Access DB, it cointains 3 values: Name, Surname and a numeric value. Now i added a column("Checkbox") because when i will click the "save" button i will need just the name and surname value of the checked rows… How can i get those values?




How can I change the value of the checkboxes using javascript

I have a function that checkes the value of a checkbox and changes it you click on the checkbox. The value has to change from 0 to 1. This problem occures with every checkbox and I can't find any information to help me. click on the checkbox the console prints out "Uncaught TypeError: teVoet is not a function at HTMLInputElement.onclick (deelEen.php:152)"

this is html code

<!-- Vervoer -->
                <legend><span class="section">10</span>Vervoer</legend>
                <p>Hoe komt de leerling naar school</p>
                <p><input type="checkbox" value="0" name="teVoet" onclick="teVoet()" ID="teVoet" />&nbsp;Te voet</p>
                <p><input type="checkbox" value="0" name="fiets" onclick="fiets()" ID="fiets" />&nbsp;Fiets</p>
                <p><input type="checkbox" value="0" name="motorfiets" onclick="motorfiets()" ID="motorfiets" />&nbsp;Motorfiets</p>
                <p><input type="checkbox" value="0" name="bus" onclick="bus()" ID="bus" />&nbsp;Bus</p>
                <p>
                    Buzzypas&nbsp;
                    <select name="buzzypas">
                        <option value="nee">Nee</option>
                        <option value="ja">Ja</option>
                    </select>
                </p>
                <p><input type="checkbox" value="0" name="trein" onclick="trein()" ID="trein" />&nbsp;Trein</p>
                <p>abonnement voor traject&nbsp;<input type="text" name="traject" /></p>
                <p><input type="checkbox" value="0" name="auto" onclick="auto()" ID="auto" />&nbsp;Auto</p>

And this is my javascript code

//scripts deelEen.php
function teVoet() {
    if (document.getElementById("teVoet").value == 0) {
        document.getElementById("teVoet").value = 1;
    } else {
        document.getElementById("teVoet").value = 0;
    }
}

function fiets() {
    if (document.getElementById("fiets").value == 0) {
        document.getElementById("fiets").value = 1;
    } else {
        document.getElementById("fiets").value = 0;
    }
}

function motorfiets() {
    if (document.getElementById("motorfiets").value == 0) {
        document.getElementById("motorfiets").value = 1;
    } else {
        document.getElementById("motorfiets").value = 0;
    }
}

function bus() {
    if (document.getElementById("bus").value == 0) {
        document.getElementById("bus").value = 1;
    } else {
        document.getElementById("bus").value = 0;
    }
}

function trein() {
    if (document.getElementById("trein").value == 0) {
        document.getElementById("trein").value = 1;
    } else {
        document.getElementById("trein").value = 0;
    }
}

function auto() {
    if (document.getElementById("auto").value == 0) {
        document.getElementById("auto").value = 1;
    } else {
        document.getElementById("auto").value = 0;
    }
}



Checkbox in specific label

It's really easy but complicated to explain:

I have checkboxes, 10 in total but there is a limit, we can only check 5 of the 10. Let's imagine that we tick a box in two and press validate. I would get a bool array that looks like this:

true, false, true, false, false, true, false, false, false, false

Knowing that each box has a value: first box = Animal second box = Capital....

Now I come to my question:

I have 5 labels and I would like it to be 5 labels corresponding to the value of the checkbox. So how to make it 5 labels is all a different value that corresponds to the checkbox.

Here is my code:

    bool[] categorie = new bool[10] { 
        false, true, false ,true ,false ,
        true ,false ,true, false, true };

    string[] categorieName = new string[10] {
       "Animaux", "Capitale", "Fruit", "Légume", "Pays", 
       "Prénom fille", "Prénom garçon", "Métier", "Moyen de transport", "Sport" };

So I have already completed the bool array but it completes itself by itself according to the checkboxes

And the second is value.

so I would like my labels to be:

Capitale, Légume, pays, prénom garcon, moyen de transport

Thank you for having and please explain a solution (loop for ? if? I don't know)




My checkbox does not stay checked once clicked (styling checkbox with css)

I am using React and pure CSS to create a checkbox list and style them.

Without styling my checkbox works perfectly, it stays checked and registers the right value.

However, when I add the styling, if I click on a checkbox, the "check" does not stay. Basically, if I hove ron the checkbox the "check" appears, but if I click it, the "check" does not persists.

My checkbox component

import React from 'react';
import '../mystyles/Dropdown.css'


function Jurisdictions(props) {
  const [selectedOpts, setSelectedOpts] = React.useState(new Set());

  function handleChange(event) {
    const value = event.target.value;
    const checked = event.target.checked;

    if (checked) {
      selectedOpts.add(value);

    } else {
      selectedOpts.delete(value);
    }

    setSelectedOpts(new Set(selectedOpts));
    props.onChange && props.onChange(Array.from(selectedOpts.values()));
  }

  return (
    <div className="dropdown-jurisdictions">
      {props.options.map((opt) => (
        <label className="item-list" key={opt}>
          {opt}
          <input
            type="checkbox"
            name="opts"
            value={opt}
            onChange={handleChange}
            className="my-checkbox"
          />
        </label>
      ))}
    </div>
  )
}


export default Jurisdictions;

My CSS styling - Dropdown.css

.dropdown-jurisdictions {
  overflow-y: auto;
  overflow-x: none;
  height: 170px;
  width: 300px;
  text-align: left;
  color: #3D5A80;
}




.my-checkbox {
  display: none;
}


label {
  display: inline-block;
  position: relative;
  padding-left: 25px;
  font-size: 16px;
  line-height: 20px;
  margin: 5px;
}
label:before {
  line-height: 20px;
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  position: absolute;
  left: 0;
  background-color: #ffffff;
  border: 1px solid #666666;
}

input[type=checkbox]:checked + label:before,
label:hover:before {
  content: "\2713";
  color: #666666;
  text-align: center;
  line-height: 16px;
}

I am pretty sure the problem is in my CSS but I cannot see the reason. Maybe because label is a not at the same level of my checkbox?




PowerShell Studio dynamic checkbox naming issue

giving the following PowerShell Studio Code, how can I call and disable the 'David Checkbox' under the 'Checkit' button. I know I am messing up on the checkbox declaration somehow because powershell does not recognize my checkbox as an object:

The property 'Enabled' cannot be found on this object. Verify that the property exists and can be set.

$accounts = "David", "Dave"

$buttonLoadLabels_Click = {
    $CheckBoxCounter = 1
    $accounts = 'didier','david'

    foreach ($account in $accounts)
    {

        $label = New-Object System.Windows.Forms.Label
        $label.Text = $account
        $label.TextAlign = 'MiddleCenter'
        $label.Font = $label1.Font
        $flowlayoutpanel1.Controls.Add($label)



        $CB = New-Object System.Windows.Forms.CheckBox
        $CB.Name = $account
        Write-Host $CB.Name
        $flowlayoutpanel1.Controls.Add($CB)




    }
}



$buttonCheckIt_Click = {


    $checkbox_David.Enabled = $false

}




$accounts = "David", "Dave"

$buttonLoadLabels_Click = {
    $CheckBoxCounter = 1
    $accounts = 'didier','david'

    foreach ($account in $accounts)
    {

        $label = New-Object System.Windows.Forms.Label
        $label.Text = $account
        $label.TextAlign = 'MiddleCenter'
        $label.Font = $label1.Font
        $flowlayoutpanel1.Controls.Add($label)



        $CB = New-Object System.Windows.Forms.CheckBox
        $CB.Name = $account
        Write-Host $CB.Name
        $flowlayoutpanel1.Controls.Add($CB)


    }
}


$buttonCheckIt_Click = {


    $checkbox_David.Enabled = $false

}



check multiple checkbox from first click to second click using jquery

Sorry for my english. I have several checkboxes like these:

<input type="checkbox" name="data[]" value="1" />1
<input type="checkbox" name="data[]" value="2" />2
<input type="checkbox" name="data[]" value="3" />3
<input type="checkbox" name="data[]" value="4" />4
<input type="checkbox" name="data[]" value="5" />5
<input type="checkbox" name="data[]" value="6" />6
<input type="checkbox" name="data[]" value="7" />7
<input type="checkbox" name="data[]" value="8" />8
<input type="checkbox" name="data[]" value="9" />9
<input type="checkbox" name="data[]" value="10" />10

If I check the checkbox number two and the checkbox number seven, it is possible to automatically check with JQUERY the checkboxes from the number two and the number seven?

<input type="checkbox" name="data[]" value="1" />1
<input type="checkbox" name="data[]" value="2" checked />2
<input type="checkbox" name="data[]" value="3" checked />3
<input type="checkbox" name="data[]" value="4" checked />4
<input type="checkbox" name="data[]" value="5" checked />5
<input type="checkbox" name="data[]" value="6" checked />6
<input type="checkbox" name="data[]" value="7" checked />7
<input type="checkbox" name="data[]" value="8" />8
<input type="checkbox" name="data[]" value="9" />9
<input type="checkbox" name="data[]" value="10" />10

Thanks!




Cannot implicitly convert type 'int' to 'bool' with if function

Hello !

I'm trying to link a Checkbox to SQL, displaying a bool value (checked = 1, unchecked = 0).
I have a misunderstanding about the Boolean demonstrated in my code.
When i build it, i get this error :

CS0029 C# Cannot implicitly convert type 'int' to 'bool'

Here's my code :

private void IsHere_Loaded(object sender, RoutedEventArgs e) // My CheckBox
        {
            object visiteur = CbSelectedName.SelectedItem; 

            SqlConnection con = new SqlConnection("MyConnString");

            SqlCommand status = new SqlCommand("SELECT column FROM table WHERE column_name = '" + visiteur + "'", con);

            con.Open();

            var result = status.ExecuteNonQuery();

            if (result = 1) // <-- CS0029 Error here

                isHere.IsChecked = true;

            else
                    isHere.IsChecked = false;
        }

Why is the if() function not correct ? Did I forget something ?
Thank you in advance,
Zancrew.




Php submit form checkbox with checked box

I have a db where read all information I read a optino and the stato 1 is confirmed and 0 not... I create a table where anyone can update, check or remove check and after the submit I update all data but in the submit I see only the "checked"... the other not..

$c_row = current($row);

if ($y > 1) {
    echo "<form name=salvo method=post action='dettaglio.php?tipo=1'>";

    $id = substr($c_row,0,strpos($c_row, '|'));
    $stato = substr($c_row,strpos($c_row, '|')+1,1);

    echo "<td class='tg-dett' align=center>";

    if ($stato == 1) {
        echo "<input type='checkbox' name='chkColor[]' value='$c_row' checked>";
    } else {
        echo "<input type='checkbox' name='chkColor[]' value='$c_row' >";
    }

    echo "</td>";

    for($i = 0; $i < count($_POST["chkColor"]); $i++)
    {
        if(trim($_POST["chkColor"][$i]) != "") {
            echo "chkColor $i = ".$_POST["chkColor"][$i]."<br>";
        }
    }
}

the output is only checked, If anyone remove a check don't appear to output




How to assign unique id to checkboxes which correspond to its row number under Bootstrap 4?

I'm designing a table to display transaction history for baby items for a javascript course. How to assign each checkbox with unique id composed of number sequence corresponding to row number?

The wireframe is shown below.

A design of the table

Each row is numbered in sequence, starting from 1 to the end of table row.

In the rightmost column, with the help of Bootstrap 4, I put a toggle checkbox, so that the user can manually choose whether to list his / her item for sale ('listing'), or end the sales ('ended').

I've been told that each checkbox id has to be unique, so I intend to name the input-id of each one 'toogle1', 'toogle2', etc, according to their respective row number.

My question is: how to auto-generate the id number?

I did a similar exercise for the row number, with the following code:

HTML:

<table id="table" data-toggle="table" data-height="800" data-pagination="true" data-page-size="3">
    <thead>
        <tr>
            <th data-field="seq-number" data-width="100" data-width-unit="px">Number</th>
        </tr>
    </thead>
</table>

JavaScript:

var table = document.getElementsByTagName('table')[0],
rows = table.getElementsByTagName('tr'),
text = 'textContent' in document ? 'textContent' : 'innerText';

for (var i = 1, rowlength = rows.length; i < rowlength; i++) {rows[i].children[0][text]= i;
}

On the other hand, my code for the table and checkbox is as follows:

<table id="table" data-toggle="table" data-height="800" data-pagination="true" data-page-size="3">
            <thead>
                <tr>
                    <th data-field="status" data-width="200" data-width-unit="px">Status</th>
                </tr>
            </thead>



<tr>
    <td>
        <input type="checkbox" id="toggle1" data-width="100">
            <script>
                 $(function () {
                 $('#toggle1').bootstrapToggle({
                 on: 'Listing',
                 off: 'Ended'
                 });
                 })
            </script>
    </td>
</tr>

I expect the input id (ie. toggle1, toggle2, ... , toggle999) can be generated and assigned automatically, corresponding to the row number.

I expect the end result with id = "'toggle' + i" .

Thank you very much for your help.




mardi 29 octobre 2019

How to add time stamp on check of checkbox in vuejs

I just started playing with vuejs. My first app attempt is a todo app with add-todo,check-if-completed and delete functionalities. I want to add a time stamp whenever a user checks a task as completed but I have no idea how to do that.




uncheck a checkbox which is checked and freezed with a condition in Angular 5

I have a table that iterates on JSON values, i have checkbox in the first column

requirement: when 5 checkboxes are selected, the user shouldn't be able to select the 6th checkbox, but he can deselect any in the 5 checkboxes

current scenario: i am able to freeze the checkboxes when the user selects 5 checkboxes but it isn't allowing me to deselect the selected checkbox

<checkbox [forbidden]="isFull() && Selected" [ngModel]="Selected" (ngModelChange)="Change(Result, $event)"> </checkbox>

checkbox is a custom component in my code base

` isFull(){
    return someService.Slots()===0; // availableSlots returns 5

} `

Change(Result, $event){ // some code irrelevant to the checkbox logic // Result holds the JSON value for iterating row }

Please provide a working plunker or any online editor for better understanding

Thanks in advance




How to display and save checkbox value from bit field in MVC?

I have a bit value in my database for something called AMD. I'm trying to display it on my page using razor and MVC, but it doesn't appear or save properly. My controller displays and saves the entire model.

My test case has a value of 0, which I try to convert to boolean, but get an error. I'm not sure if the best way to do it is to convert it to boolean, or if I could just outright use 1 and 0 to check the checkbox. I'll also need it to be 1 or 0 when it saves.

Things I've tried in the view:

(cannot convert int? to bool)

@Html.CheckBox(Convert.ToBoolean(Model.Detail.AMD))

(cannot convert int? to bool)

<label class="label4">@Html.CheckBoxFor(x => x.Detail.AMD)</label>

(always checked, despite the AMD value in the database being 0; value also stays 0 when clicking save)

<input type="checkbox" name="isChecked" class="checkbox" value="@Model.Detail.AMD"
checked="@Html.Raw(Convert.ToBoolean(Model.Detail.AMD) ? "checked" : string.Empty)" />

The controller is very generic:

(page load)

Manager.GetDetails(id);

(page save)

Manager.SaveDetails(model.Detail);

Any help is appreciated. I am open to learning.




How to create a checkbox in a server generated pdf?

I have a node js server running where I am creating reports in pdf format. I want to implement check-boxes in the pdf as well. Currently I'm using pdfmake library for node but it does not seem to have any options for check-boxes.

So my question is, is it possible to make check-boxes in the pdf when generating programmatically through the server. If yes which library can be used for that or if pdfmake have some kind of option because the documentation is not that clear. Thanks!




the check-state of checkbox of QTreeView (item with SetCheckable(true)) not update after setCheckState()

guys, I got one issue that the check-state of checkbox of QTreeView (item with SetCheckable(true)) not update after setCheckState(). my intention is: include a QTreeView in a QDialog. in this QTreeView, the items are with check-box enabled through QStandardItem::SetCheckable(), and set TriState enabled for items that has children. when clicked any item, I 'd like to update its ancestor items' check-state: 1. when all children checked, set Qt::Checked for the parent, 2. when all children unchecked, set Qt::Unchecked for the parent, 3. otherwise, set Qt::PartiallyChecked for the parent, below is some code in which I derived a class from QStandardDataModel:

void TriStateItemModel::setCheckStateNumForAllNodes() 
{
    connect(this, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(itemCheckStateChanged(QStandardItem*))); 
}

void TriStateItemModel::itemCheckStateChanged(QStandardItem* pItem)
{
    if((NULL == pItem) || (!pItem->isCheckable()))
        return;
    QStandardItem* parent = pItem->parent();
    if(parent == NULL) return;

    if(NULL != parent)
    {
        int brotherCount = parent->rowCount();
        int checkedCount(0),unCheckedCount(0);
        Qt::CheckState state;
        for(int i=0; i<brotherCount; ++i)
        {
            QStandardItem* siblingItem = parent->child(i);
            state = siblingItem->checkState();
            if(Qt::Unchecked == state)
                ++unCheckedCount;
            else if(Qt::Checked == state)
                ++checkedCount;
        }

        if(checkedCount>0 && unCheckedCount>0)
            parent->setCheckState(Qt::PartiallyChecked);
        else if(checkedCount == brotherCount)
            parent->setCheckState(Qt::Checked);
        else if(unCheckedCount == brotherCount)
            parent->setCheckState(Qt::Unchecked);
    }
}

but it runs not expected:
    when click one item, its parent's check-box not update accordingly (but its check-state truly updated when I check it by:

if(pItem->parent()->checkState()==Qt::Checked)
{
    qDebug() << "parent checked-state";
}

could anyone help on this? enter image description herethanks ahead.




lundi 28 octobre 2019

shouldn't uncheck checkbox in certain conditions

<input type="checkbox" [(ngModel)]="rowData.forA">  // checkbox A
<input type="checkbox" [(ngModel)]="rowData.forB">  // checkbox B
<input type="checkbox" [(ngModel)]="rowData.forC">  // checkbox C

I have these checkbox. And a model:

class Book {
  name: string;
  forA: boolean;
  forB: boolean;
  forC: boolean;
}

forA forB forC mean the book should be used in condition A, condition B or condition C.

In some conditions, if checkbox A is checked, and it's used in a kind of condition A, you cannot uncheck it. how to do that?




How to replace url instead add/push with this code

I found this code to change the url depending on which checkbox is selected here: Change href depending on checkboxes But I need to go one step before or replace the url instead add/push on the existing url. Like I'm on www.katana.com/e-bikes/ and I need to go to https://ift.tt/31V3BTS not want to stay on e-bikes and continue pushing the url.

I don't know if I have to change the push method or the problem is the "this" selector that adds the existing url.

Thank you so much!!!

var one ="111";
var two ="222";
var three ="333";

$('body').append('<a href=\"' + one + "," + two + "," + three + '\">link</a>'); //this is the default value

$('.checkbox').change(function() {
    var href = "";
    if ($('#one').is(':checked')) {
        href = one;
    }
    if ($('#two').is(':checked')) { 
        href += (href != "") ? "," + two : two;
    }
    if ($('#three').is(':checked')) {
        href += (href != "") ? "," + three : three;
    }
    $("a").attr("href", href);
});



Bootstrap custom checkbox render bug when using CSS column-width

I use Bootstrap's (version 4) custom checkboxes. If I align them using column-width in their parent container, the checkboxes in the last column do not appear in IE 11. In Chrome and FF it is OK.

The label text is visible but the pseudo-elements which contain the actual custom checkbox are not. Do you have any workaround for this render bug?

Below is my code and you can check it here in JS Bin: https://jsbin.com/wacilucepa/1/edit?html,css,output

CSS:

.container {
  column-width: 100px;
  box-sizing: border-box;
}

HTML:

<div class="container">
    <div class="custom-checkbox custom-control">
      <input type="checkbox" class="custom-control-input" id="check1"/>
      <label class="custom-control-label" for="check1">test1</label>
    </div>
    <div class="custom-checkbox custom-control">
      <input type="checkbox" class="custom-control-input" id="check2"/>
      <label class="custom-control-label" for="check2">test2</label>
    </div>
    <div class="custom-checkbox custom-control">
      <input type="checkbox" class="custom-control-input" id="check3"/>
      <label class="custom-control-label" for="check3">test3</label>
    </div>
    <div class="custom-checkbox custom-control">
      <input type="checkbox" class="custom-control-input" id="check4"/>
      <label class="custom-control-label" for="check4">test4</label>
    </div>
    <div class="custom-checkbox custom-control">
      <input type="checkbox" class="custom-control-input" id="check5"/>
      <label class="custom-control-label" for="check5">test5</label>
    </div>
    <div class="custom-checkbox custom-control">
      <input type="checkbox" class="custom-control-input" id="check6"/>
      <label class="custom-control-label" for="check6">test6</label>
    </div>
  </div>



React input checkbox not updating state indirectly

Unfortunately I didn't understand logic of input checkbox in render. Here is the problem:

1) I have input type checkbox with onChange and checked attributes on it;
2) Also I have button handleSearch which gets API information from backend after clicking the button;
3) If I will click on checkbox it will also receive information from API(from same API as in second step with same parameters).

Problem is: If I will click checkbox it will send falsy parameter of checkbox because, as I understand, it is working vice-versa for some reason. But, if I will try to first click button it will work OK.

So I need to send truthy parameter on handling checbox.

input in render():

    <input
        type="checkbox"
        className="custom-control-input"
        name="grouping"
        id="updateprice"
        checked={grouping}
        onChange={this.onGroupingChange}
    />      

checkbox handler():

      onGroupingChange = (e) => {
         const {grouping} = this.state;
        this.setState({ grouping: e.target.checked});
             this.getSales(grouping);
    };

OnClick handler():

      handleSearch = () => {
        const { grouping  } = this.state;
        this.setState({ isLoading: true });
        this.getSales(grouping);
    };

getSales()

getSales = (grouping) => {
        let notattr;
        if (grouping===false){
            notattr=1
        }
        else notattr = 0
        this.setState({isLoading: true})
        Axios.get('/api/report/sales', {
            params: { notattr }

        })
        .then(res => res.data)
            .then((sales) => {
                this.setState({
                    sales,
                    isLoading: false,
                    handleGrouping: true,
                    activePage: 1,
                    currentRange: {
                        first: (this.state.itemsPerPage) - this.state.itemsPerPage,
                        last: (this.state.itemsPerPage) - 1
                    },
                    orderBy: ''
                })
            })
            .catch((err) => {
                this.setState({isLoading: false})
                console.log(err)
            })
    };

basic problem scenario 1:
1) I'm opening page;
- checkbox in screen true;
2) I'm clicking search button;
- API sends noattr:0 because grouping:true;
3) Now, I want to click checkbox;
- API still sends noattr:0 because grouping:true(but I was expecting grouping:false value)
4) If I will handle checkbox later it will work vice-versa. But if I will handle search button, it will send OK information.
Obviously there is small mistake somewhere, but I tried a lot of different combinations and it seems that didn't find right one.




Label is showing under checkbox and both should be center aligned

I am confused. I got this form, jsfiddle:

https://jsfiddle.net/rx90f38u/1/

It has the styling in there and I can't work out why "remember" me shows under the checkbox.

The checkbox and label should be on same line and centered.

CSS:

.bbp-login-form input[type=text], .bbp-login-form input[type=password], .bbp-login-form select {
  width: 100% !important;
  display: inline-block !important;
  border: 1px solid #ccc;
  border-radius: 4px;
    -moz-border-radius:4px;
  -webkit-border-radius:4px;
  box-sizing: border-box;
    color: #000;
    background-color: #c1c1c1;
}

.bbp-login-form label {
    text-align:left;
  width: 100% !important;
  margin: 10px 0;
  display: inline-block !important;
}

HTML:

<!DOCTYPE html>
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 1</title>
</head>

<body>

<h2 class="widgettitle">Support Forums</h2>
<form action="https://www.publictalksoftware.co.uk/wp-login.php" class="bbp-login-form" method="post">
    <fieldset>
    <div class="bbp-username">
        <label for="user_login">Username: </label>
        <input id="user_login" name="log" size="20" tabindex="103" type="text" value="">
    </div>
    <div class="bbp-password">
        <label for="user_pass">Password: </label>
        <input id="user_pass" name="pwd" size="20" tabindex="104" type="password" value="">
    </div>
    <div class="bbp-remember-me">
        <input id="rememberme" name="rememberme" tabindex="105" type="checkbox" value="forever">
        <label for="rememberme">Remember Me</label> </div>
    </fieldset></form>

</body>

If I add this CSS then I get Remember Me center:

.bbp-login-form .bbp-remember-me label {
    text-align: center;
  width: 50%;
}

But even if I reduce the width still a problem.




Can i submit form and selected checkbox?

I have a purchase order page in that page i have form like below

<form action="" method="post">
                <div class="container">
                    <div class="row">
                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Tanggal PO</label>
                                <input class="form-control" type="text" name="tanggal_po" id="datepicker">
                                {!! $errors->first('tanggal_po','<span class="text-danger">:message</span>') !!}                                                                                        
                            </div>

                            <div class="form-group">
                                <label>No Po</label>
                                <input class="form-control" type="text" name="no_po">
                                {!! $errors->first('no_po','<span class="text-danger">:message</span>') !!}                                                            
                            </div>

                            <div class="form-group">
                                <label>Supplier</label>
                                <select name="supplier_nama" class="form-control">
                                    <option value=""hidden>Pilih Supplier</option>
                                    @foreach ($supplier as $s)
                                        <option value=""></option>
                                    @endforeach
                                </select>
                            </div>
                        </div>

                        <div class="col-md-6">
                            <div class="form-group">
                                <label>Apoteker</label>
                                <select name="apoteker_nama" class="form-control">
                                    <option value=""hidden>Pilih Apoteker</option>
                                    @foreach ($apoteker as $a)
                                        <option value=""></option>
                                    @endforeach
                                </select>
                            </div>

                            <div class="form-group">
                                <label>Keterangan</label>
                                <input class="form-control" type="text" name="keterangan">
                            </div>
                        </div>
                    </div>
                </div>

                <button type="submit" class="btn btn-success simpan"><i class="fas fa-check"> Simpan</i></button>

and i also have a table

 <table class="table table-bordered" style="margin-top:20px">
             <tbody>
                 <tr class="text-center">
                     <th>No</th>
                     <td>Kode Obat</td>
                     <td>Nama Obat</td>
                     <td>Harga Obat</td>
                     <td>Jumlah Obat PO</td>
                     <td>Harga Obat PO</td>
                 </tr>
                 @foreach ($obat as $o)
                 <tr>
                            <td class="text-center">
                                    <input id="" type="checkbox" name="select">
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="" class="form-control" type="text" name="kode_obat" value="" readonly>                                        
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="" class="form-control" type="text" name="nama_obat" value="" readonly>
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="harga" class="form-control" type="text" onkeyup="sum()" value="" readonly>
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="jumlah" class="form-control" onkeyup="sum()" type="text" name="jumlah">
                                </div>
                            </td>
                            <td>
                                <div class="form-group">
                                    <input id="total" class="form-control" type="text" onkeyup="sum()" name="harga_obat" readonly>
                                </div>
                            </td>

                        
                    </tr>
                    @endforeach
             </tbody>
         </table>

in that table there is a checkbox name select, i want when i input the form and select the checkbox i can click on the submit button, both the form and checkbox can be insert into database.

the checkbox name="select" is from purchase_order table. this is my migration table

$table->increments('id');
$table->date('tanggal_po');
$table->string('select');
$table->string('no_po');
$table->string('supplier_nama');
$table->string('apoteker_nama');
$table->string('kode_obat');
$table->string('nama_obat');
$table->integer('jumlah')->unsigned()->nullable();
$table->string('harga_obat');
$table->string('keterangan');



dimanche 27 octobre 2019

hamburger menu behind a checkbox on mobiles but it does not work

I have a simple hamburger menu with a checkbox, for my navigation. However in the mobiles I am faced with the hamburger and the checkbox, it is not going behind the hamburger. I am not an expert with CSS but I have tried to get it to work to no avail.

#page-nav {width: 100%;}
#page-nav label, #hamburger {display: none;}
#page-nav ul {font-family: 'Monserrat' sans-serif; font-size: 18px; color: white; list-style-type: none; margin: 0; padding: 0;}
#page-nav ul li {text-align: center; display: inline-block; padding: 10px; width: 11.11%; box-sizing: border-box;}
#page-nav ul li a {color: #fff; text-decoration: none;}a {text-decoration: none; color: #232323; transition: color 0.3s ease;}
li:visited {background: #0000EE; color: #fff;}
li:active, .active {background: #0000EE; color: #fff;}
li:hover {background: #0000EE; color: #fff;}

  /* Show Hamburger */
@media screen and (max-width: 768px){
#page-nav {background-color: #3333FF;}
#page-nav label {display: inline-block; color: #fff; background: #3333FF; font-style: normal; font-size: 2em; padding-bottom: 8px; padding-right:-50px; z-index: 3; transition: color 0.3s ease;}
#page-nav ul {display: none;}
#page-nav ul li {width: 22.22%; display: block; border-top: 1px solid #333;}
#page-nav input[type=checkbox]checked ~ ul{display: block; }
#page-nav ul li:active {display: inline;}```

html ```<nav id="page-nav"><label for="#hamburger">&#9776;</label><input type="checkbox">
<ul>
<li><a href="http:/index.html">Home</a></li>
<li><a href="http:/contacts.html">Contacts</a></li>
<li class="active"><a href="http://news.html">News</a></li>
<li><a href="http://members.html">Members</a></li>
<li><a href="http://policies.html">Policies</a></li>
<li><a href="http://www.hubb.org.uk/volunteer.html">Volunteer</a></li><li><a href="http://links.html">Links</a></li></ul></nav>



Can I limit an onEdit function to a checkbox cell in Google Sheets?

I'm creating a spreadsheet in Google Sheets to collect and analyse individual inputs. The idea was to have users input data on the first sheet, hit a Submit button, and have it collected in another sheet, while clearing the first sheet inputs. I figured it out with a button, but I learned afterwards that buttons don't work on mobile, which will be the main method of use.

So, I'm wondering if there's a way to limit an 'onEdit' function to a single checkbox. i.e. I'd like to fill in the info without any functions going off, then when the user is ready, click the checkbox to send the info, which then sets the checkbox to false, and resets the input cells.

Is this possible?




React:How to display text in textarea from selected checkboxes?

Dears, How to display text from selected checkboxes in textarea? In Vue.js it was easy but whats the simplest way to do it in React? Thank you for the answers!

Below you can find a example i made in Vue i want to make something similar in React.

<template>
<div class="custom-checkbox">
<input type="checkbox" v-model="resolved" class="custom-control-input" id="customChk8" value="Ticket Resolved">
<label class="custom-control-label" for="customChk8">Ticket Resolved</label>

<textarea></textarea>

</template>

<script>
export default {
  name: 'solvedcases',
  data () {
    return {
      isSelected: [] , 
      show: true
    }
  },
  methods: {
    click () {
      // do nothing
    },
  }
}
</script>



Chane text color if checkbox is disabled

How can I change the label color for this checkbox if the checkbox is disabled change the text color to red and if it's not change to green.

Here is my code:

<?php
if ($timelists[]='09:00:00'){
?>
<div class="checkbox checkbox-success checkbox-info text-danger">
<input id="checkbox-15" type="checkbox" name="timelist[]"value="09:00:00" <?php echo (in_array("09:00:00", $timelists)?"disabled='disabled'":"") ?>>
<label for="checkbox-15">
09:00 AM - 10:00 AM (ALREADY SCHEDULED)
</label>
</div>
<?php
}
else{
?>
<div class="checkbox checkbox-success checkbox-info text-success">
<input id="checkbox-15" type="checkbox" name="timelist[]"value="09:00:00" <?php echo (in_array("09:00:00", $timelists)?"disabled='disabled'":"") ?>>
<label for="checkbox-15">
09:00 AM - 10:00 AM (AVAILABLE)
</label>
</div>
<?php
}
?>

In This case the checkbox is disabled and label color is red 'text-danger' I got the same ouput when is not disabled and supposed to be the label color is green 'text-success'




samedi 26 octobre 2019

How to get Selected checkbox into database

I have a page for purchase order in that page i show data from table obat and i want to get selected checkbox using that data into table purchase order

This is my table obat


         <table class="table table-bordered" style="margin-top:20px">
             <tbody>
                 <tr class="text-center">
                     <th>No</th>
                     <td>Kode Obat</td>
                     <td>Nama Obat</td>
                     <td>Harga</td>
                 </tr>
                 @foreach ($obat as $key =>$o)
                 <tr>
                     <th class="text-center">
                        @foreach ($po as $po)
                             <input type="checkbox" name="select" id="select">     
                        @endforeach
                    </th>
                     <td>
                        <input type="text" class="form-control" value="">
                    </td>   
                     <td>
                        <input type="text" class="form-control" value="">     
                    </td>   
                     <td>
                         <input type="text" class="form-control" value="">
                     </td>
                 </tr>
                 @endforeach  
             </tbody>
         </table>

The checkbox(select) is from table purchase order but it can't show. if i did't use foreach its show




Javascript can't get checkbox values to display string of information

I'm trying to build a simple order form in HTML, CSS and Javascript. I'm a beginner and am trying to have the input display a summary of the order as the user selects their order. I was able to make this work with radio buttons by doing the following:

HTML:

<input type="radio" name="crust"  onclick="crustOfPizza(this.value)" value="Original"> Original <br>
<input type="radio" name="crust"  onclick="crustOfPizza(this.value)" value="Garlic and Herb"> Garlic and Herb <br>
</form>

<p> Crust: </p> <output id="pizzaCrust"> </output> </br>

Javascript:

function crustOfPizza(crust) {
  document.getElementById("pizzaCrust").value = crust;  
}

However, I can't seem to get a similar result with checkboxes. I've tried the following:

HTML:

    <input type="checkbox" name="meat" onclick="meatOnPizza()" value="Sausage">Sausage<br>
    <input type="checkbox" name="meat" onclick="meatOnPizza()" value="Bacon">Bacon<br>
    </form>

<p> Meat: </p> <output id="pizzaMeat"> </output>    

Javascript:

  var meat = document.forms[0];
  var txt = "";
  var i;
  for (i = 0; i < meat.length; i++) {
    if (meat[i].checked) {
      txt = txt + meat[i].value + " ";
    }
  }
  document.getElementById("pizzaMeat").value = txt;
}

I appreciate any guidance anyone can offer!

Jessica




vendredi 25 octobre 2019

Displaying Message based on different checkbox combinations

We have a series of 10 check boxes. We are attempting to get a message to display depending on the series of check boxes selected. However, our problem is that upon pressing the button it shows all of the possible combinations.

Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

If CheckBox1.Checked = True And CheckBox6.Checked = True Then MessageBox.Show("On Campus Student Center")

If CheckBox1.Checked = True And CheckBox7.Checked = True Then MessageBox.Show("On Campus Marketplace")

If CheckBox1.Checked = True And CheckBox8.Checked = True Then MessageBox.Show("Around Campus")

If CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox9.Checked = True Then MessageBox.Show("2 Mile Restaurant")

If CheckBox2.Checked = True And CheckBox3.Checked = True And CheckBox10.Checked = True Then MessageBox.Show("2 Mile FF")

If CheckBox2.Checked = True And CheckBox4.Checked = True And CheckBox9.Checked = True Then MessageBox.Show("3 Mile Restaurant")

If CheckBox2.Checked = True And CheckBox4.Checked = True And CheckBox10.Checked = True Then MessageBox.Show("3 Mile FF")

If CheckBox2.Checked = True And CheckBox5.Checked = True And CheckBox9.Checked = True Then MessageBox.Show("4 Mile Restaurant")

If CheckBox2.Checked = True And CheckBox5.Checked = True And CheckBox10.Checked = True Then MessageBox.Show("4 Mile FF")

If CheckBox1.Checked = True And CheckBox6.Checked = True And CheckBox7.Checked = True And CheckBox8.Checked = True Then MessageBox.Show("All On Campus")

If CheckBox1.Checked = True And CheckBox6.Checked = True And CheckBox7.Checked = True Then MessageBox.Show("Student Center and Marketplace")

If CheckBox1.Checked = True And CheckBox6.Checked = True And CheckBox8.Checked = True Then MessageBox.Show("Student Center and Around Campus")

If CheckBox1.Checked = True And CheckBox8.Checked = True And CheckBox7.Checked = True Then MessageBox.Show("Market Place and around")

End Sub

End Class

For example if we follow the checkbox selection of the last statement. Check boxes 1,7, and 8. We get the following message boxes, "On Campus Market Place", "Around Campus", and "Marketplace and around". Where as we only want it to show text for the final if statement.




Java - incorrect action at selecting a checkbox

I work on Java FX.
I have a tableview in which I created a "select checkbox" column. The goal is when a user clicks on a checkbox, an alert message appears.
To test it, I first tried to display a System.out.println message.
The problem are :

  • when I only select one checkbox, I have a System.out.println message that writes all the checkboxes :
com.calculatrice.app.model.Person@34752060
com.calculatrice.app.model.Person@654bd7bc
com.calculatrice.app.model.Person@74bbebe0
com.calculatrice.app.model.Person@2e23be4f
com.calculatrice.app.model.Person@3348edcb
com.calculatrice.app.model.Person@8052a29
com.calculatrice.app.model.Person@23ca3422
com.calculatrice.app.model.Person@102837d2
com.calculatrice.app.model.Person@647ab6a9
  • when I select nothing, I have the same System.out.println message

How could I do to have a message with item(s), corresponding to the checkbox(es) selected ?

Here is my snippet :

  private void selectCheckBox(ActionEvent ae) {
         // personTable is the Tableview ; Person is the class where the getter is declared
        for(Person p : personTable.getItems()){
            if (p.getSelect().isSelected()){
                System.out.println (p + " is selected");
            }
        }
}



How to display checked check boxes together with non-checked ones

I have 5 check boxes from which a user can select one or more choices. The selected choices are then updated in database. The user's choices are then displayed/reviewed on another page. However my issue is that I want to show the updated choices together with the non-selected choices when doing a foreach loop in PHP.

These are the 5 check boxes

<input type="checkbox" name="interest[]" value="fishing">Fishing
<input type="checkbox" name="interest[]" value="camping">Camping
<input type="checkbox" name="interest[]" value="hiking">Hiking
<input type="checkbox" name="interest[]" value="swimming">Swimming
<input type="checkbox" name="interest[]" value="running">Running

<br><br>
<input type="submit" name="submit" value="Submit">

Heres the code that updates

if (isset($_POST["submit"])) {

 $interestArr = $_POST['interest'];


$interest = new Interest();
$newArr = implode(',', $interestArr);

$interest->updateInterests($id=19, $newArr);

}

Heres the code that displays

<?php 

 $interest = new Interest();
 $interests = $interest->showInterests($userid=19)->interests;

 $newArr = explode(',', $interests);

 foreach ($newArr as $data) {

 echo '<input type="checkbox" name="interest[]" value="'.$data .'" checked>'.$data;
}

The update choices are stored under the interests column in DB like so fishing,camping,running

And the foreach loop displays them checked check box with the correct corresponding labels.

How can I display the other check boxes that were not selected just so that the user might want to make changes?

Thanks.




jeudi 24 octobre 2019

How to add a checkbox in InstallDir Dialog?

I found some articles which says that we need to add WixUI_InstallDir.wxs and InstallDirDlg.wxs files to our WiX source code and have to edit them to add a checkbox. But, I don't find InstallDirDlg.wxs to edit and incude it in my wix source code. I am using WiX 3.11.1 version and please let me know the best way to add a checkbox.




Checking a check-box in one sheet tab will update another checkbox in a different sheet tab

I have an inventory list in one tab with all the items including barcodes for every item. On the far right side of the sheet, I have code that when a checkbox is selected, the item row information is copied over to another tab which is our checkout page. The checkbox is included on this page, and it stays selected. I really want to be able to deselect the checkbox, which would delete the row from the checkout tab, and deselect the checkbox from the inventory tab. Is there a way to do this? At the very least, I would love to be able to deselect the checkbox on the checkout tab which would automatically deselect the same checkbox on the inventory tab, and then manually delete the row. Is any of this possible? here is my current code:

I have tried to find other posts, but anything that involves deselecting a box will create a new row at the bottom. This isn't what I want since my inventory list is in order from a barcode, and I don't want to create duplicates.

function onEdit(event) {
  // assumes source data in sheet named main
  // target sheet of move to named Completed
  // getColumn with check-boxes is currently set to colu 4 or D
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = event.source.getActiveSheet();
  var r = event.source.getActiveRange();
  if(s.getName() == "Tech Lending" && r.getColumn() == 5 && r.getValue() == true) {
    var row = r.getRow();
    var numColumns = s.getLastColumn();
    var targetSheet = ss.getSheetByName("Check-out");
    var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
    s.getRange(row, 1, 1, numColumns).copyTo(target);

  }
}



use checkbox in angular

I want to use a checkbox in my form except that it does not appear. I only have the label. I do not have the checkbox to check

    <div class="form-check">
        <label class="form-check-label">
          <input class="form-check-input" type="checkbox" name="origine" value="ami" checked>
          Par un ami 
        </label>
    </div>



Html.CheckBoxfor() in for loop does not display checkbox

Trying to iterate over a list in my view to display user preferences and if they're hecked or not.

Here is what I have for now in my view:

 @for (var i = 0; i < Model.IdentityFields.FieldDefinitions.Count(); i++)
            {
                @Html.HiddenFor(m => m.IdentityFields.FieldDefinitions[i].Id)
                @Html.CheckBoxFor(m => m.IdentityFields.FieldDefinitions[i].IsActivated)
                @Html.Raw(Model.IdentityFields.FieldDefinitions[i].Name)
                @Html.Raw(Model.IdentityFields.FieldDefinitions[i].ApiKey)
                <br/>
            }

But checkboxes are not displayed.

enter image description here

Anyone can see if I'm doing something wrong here? Thanks for helping !




Disabling a checkbox when another checkbox is clicked

I am trying to disable the thin and crispy checkbox when traditional checkbox is clicked. I have these in a group due to me enabling the whole group when the numericUpDown value is set to 1. When I click traditional checkbox, it doesn't disable the thin and crispy checkbox. I am using windows form application

Code

        private void NudQuantity1_ValueChanged(object sender, EventArgs e)
        {

            if (NudQuantity1.Value == 0)
            {
                gbCheesePizza.Enabled = false;
            }
            else
            {
                gbCheesePizza.Enabled = true;
            }

            if (CBXTraditional1.Checked == true)
            {
                CBXthinandcrispy1.Enabled = false;
            }

        }

When I run this code outside of a groupbox, it works perfectly.




Shiny, checkboxInput and observeEvent

Given this small shiny app:

library(shiny)
library(tidyverse)
library(shinydashboard)

ui = dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(uiOutput("graphs_ui")),
)

server <- function(input, output, session) {

  popup <- function(){ modalDialog(easyClose = T,'popup window triggered')}

  output$graphs_ui <- renderUI({
    map(1:2, ~{
      tagList(box(title = paste0("Isolation: ", .x),

                  status = "info",
                  footer = checkboxInput(paste0("check_", .x),"")))})
  })

  observeEvent(map(grep(pattern = "check_", names(input), value = TRUE), ~input[[.]]),{
    showModal(popup())}, ignoreInit = T)
}

shinyApp(ui, server)  

I want to trigger a dialog "popup" upon checking one of the checkboxes. Problem is that the dialog already pops up after initalizing the app, althoug I set ignoreInit = TRUE. I have no idea why, since the behavior remains when using actionButton.




$NaN Displaying instead of the total cost

So I have an assessment due tomorrow, I am almost complete however stuck on one last thing... My total cost summary. I have a booking summary and everything displays fine apart from the total cost, it just displays "$NaN"

I have looked up other examples but they are all basic (for example: var example = 4 + 4 + 5;)

Here is my main loop:

function loopForm(form) { // Main function that gathers inputs for booking summary aswell as firebase
    alert('Test alert for confirm booking'); // Test alert to see if function is working
    var amountOfDays = numberOfDays.value; // Defining the amount of days for the calculation(s)
    var insuranceFee = 20; // Defining the insurance fee
    var BOOKINGFEE = 50; // Defining the Booking fee
    var sum = 0 ; // Setting the sum variable to 0
    var cbResults = ' '; // Setting the extras to nothing so when there is something called, it won't save for the next booking
    outputEmail.innerHTML = emailInput.value; // Gathering the input of the email, storing it as a output for the booking summary
    outputComment.innerHTML = furtherCommentsInput.value; // Gathering the input of the further comments, storing it as a output for the booking summary
    outputDropOff.innerHTML = dropOffDate.value; // Gathering the input of the drop off date, storing it as a output for the booking summary
    for (var i = 0; i < form.elements.length; i++) { // For loop checking the elements
        if (form.elements[i].type == 'radio') { // If statement for the chosen vehicle (because its done in radios)
            if (form.elements[i].checked == true) { // If the radio is checked...
                vehicleResult = form.elements[i].value; // Gathering the chosen vehicle and storing it as "vehicleResult"
                vehicleCost = form.elements[i].dataset.price; // Gathering the cost of the chosen vehicle, storing it as "vehicleCost" for cost calculations 
                insuranceCost = Math.round(insuranceFee + vehicleCost * amountOfDays); // Calculating the cost of the vehicle, amount of days and insurance
                outputDays.innerHTML = amountOfDays; // Gathering the input of the amount of days, storing it as a output for the booking summary
                outputVehicle.innerHTML = vehicleResult; // Gathering the input of the chosen vehicle, storing it as a output for the booking summary
            }
        }
        if (form.elements[i].type == "checkbox") { // If statement for the chosen extras (because its done in checkboxes)
            if (form.elements[i].checked == true) { // If the checkbox is checked...
                cbResults += form.elements[i].value + ', '; // Checking how many extras the user has chosen
                sum = sum + parseInt(form.elements[i].dataset.price); // Calculating the cost of all the chosen extras 
                alert(cbResults + "$" + sum); // Sends a test alert to show the chosen extras
                outputExtras.innerHTML = cbResults; // Gathering the input of the chosen extras, storing it for the booking summary
                totalCost = Math.round(insuranceCost + sum + BOOKINGFEE); // Calculating the total cost
                outputCost.innerHTML = '$' + totalCost; // Gathering the input of the total cost, storing it for the booking summary
            }
        }
    }
}

I expect the total cost to be worked out and displayed in the booking summary.

p.s - ignore the code comments I need them there to pass




Disable checkbox if the value is already in databse

I am having trouble disabling checkbox if the value are already in db.

I have tablename staff_availability and it has column from the datatype is time. I have multiple values for from (e.g. 09:00:00, 10:00:00 and so on...) I tried this but it disabled all the checkbox. Here is my code:

include 'dbconfig.php';
$upload_dir = 'uploads/';
 $id = $_SESSION['stfid'];
$sql="SELECT * FROM staff_availability  WHERE stfid = '$id'";
$result = mysqli_query($conn,$sql);
if (mysqli_num_rows($result)>0) {
while($row = mysqli_fetch_array($result)) {
$timelists[] = $row['fro'];
}
}
mysqli_close($conn);
?>
                                            <div class="checkbox checkbox-success checkbox-info">
                                                    <input id="checkbox-15" type="checkbox" name="timelist[]"value="09:00:00" <?php echo (in_array("09:00:00", $timelists)?"disabled='disabled'":"") ?>>
                                                    <label for="checkbox-15">
                                                        09:00 AM - 10:00 AM 
                                                    </label>
                                            </div>
                                            <div class="checkbox checkbox-success checkbox-info">
                                                    <input id="checkbox-15" type="checkbox" name="timelist[]"value="10:00:00" <?php echo (in_array("10:00:00", $timelists)?"disabled='disabled'":"") ?>>
                                                    <label for="checkbox-15">
                                                        10:00 AM - 11:00 AM
                                                    </label>
                                            </div>
                                            <div class="checkbox checkbox-success checkbox-info">
                                                    <input id="checkbox-15" type="checkbox" name="timelist[]"value="11:00:00" <?php echo (in_array("11:00:00", $timelists)?"disabled='disabled'":"") ?>>
                                                    <label for="checkbox-15">
                                                        11:00 AM - 12:00 PM
                                                    </label>
                                            </div>



mercredi 23 octobre 2019

Checkboxes firing on all records instead of the selected record

I'm building a form that contains a subform to list records as a datasheet. The fields on the subform are sourced from a saved query. To the subform, I added a checkbox control to serve as a record selector.

Here is the problem: When I click on the checkbox of specific record on the subform, ALL the checkboxes on all the records display a check rather than just the one I clicked. I cannot figure out what is causing this undesirable behavior.

Any insights or suggestions to fix this is much appreciated.




checkbox to php database

Hi I am working on an assignment to input 3 checked items into my database. I can't use arrays for this.

Here is my form:

 <p>What are your categories of interest? (Select as many as you'd 
 like below)</p>
 <input name="industry" type="checkbox" value="industry" 
 />Industry<br />
 <input name="technical" type="checkbox" value="technical" 
 />Technical<br />
 <input name="career" type="checkbox" value="career" />Career<br />

Here is my php:

$name = $_POST["name"];
$email = $_POST["email"];
$industry = $_POST["industry"];
$technical = $_POST["technical"];
$career = $_POST["career"];
$role = $_POST["role"];

include("includes/dbconfig.php");

$stmt = $pdo->prepare("INSERT INTO `contacts` (`contactid`, `name`, 
`email`, `industry`, `technical`, `career` `role`) VALUES (NULL, 
'$name', '$email', '$industry', '$technical', '$career', 
'$role');");

$stmt->execute();

header("location:contactthankyou.php");



?>

and my database table has 3 columns (industry, technical, career).

NOTHING WORKS please help




Adding checkbox list of features in creating a new Car class

I'm developing something like portal for adding car ads. I really can't understand how to add a checkbox list to add in my AudiCarModel Class. I have all the properties for creating a new object, but i want to add different features which are able to be added. I need help i my AudiModelCar Class, some kind of a new class or enum or just list in the Controller. And create view code to implement it, of course

I've tried with enum class but it didn't happen

public class AudiCarModel
{
    [Key]
    public int AudiId { get; set; }


    [Required(ErrorMessage = "Моля, въведете категория")]
    [Display(Name = "Категория")]
    public AudiCategory AudiCategory { get; set; }


    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете модел")]
    [Display(Name = "Модел")]
    public AudiModel AudiModel { get; set; }


    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете цена")]
    [Display(Name = "Цена")]
    public decimal AudiPrice { get; set; }


    [Required(ErrorMessage = "Моля, въведете тип двигател")]
    [Display(Name = "Двигател")]
    public AudiEngineType AudiEngineType { get; set; }

    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете обем на двигателя")]
    [Display(Name = "Обем")]
    public double AudiCubics { get; set; }

    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете конски сили")]
    [Display(Name = "HP")]
    public int AudiHP { get; set; }


    [Required(ErrorMessage = "Моля, въведете година")]
    [Display(Name = "Година")]
    public AudiYearProduced AudiYearProduced { get; set; }


    [Required(ErrorMessage = "Моля, въведете тип скоростна кутия")]
    [Display(Name = "Скоростна кутия")]
    public AudiTransmission AudiTransmission { get; set; }


    public List<FeatureEnumModel> CheckBoxFeatures { get; set; }
    //I accept any new approach - not enum, list of features is ok!

    [Required(ErrorMessage = "Моля, въведете населено място")]
    [Display(Name = "Населено място")]
    public AudiLocation AudiLocation { get; set; }

    [Required(ErrorMessage = "Моля, въведете телефонен номер")]
    [Display(Name = "Телефон")]
    public int PhoneNumber { get; set; }

    [Required(ErrorMessage = "Моля, въведете електронна поща")]
    [Display(Name = "Електронна поща")]
    public string Email { get; set; }

}

}

I need some help in the Controller Create(action), and in the Create(view).




How to make a always unchecked checkbox without using disabled in vue.js?

I need the checkbox to be always unchecked. I tried by binding the checked attribute to a false property from data and set @input/change listener to do nothing and using v-model but none of them does work as expected.

Code here




Show / Hide children of an li when checkbox is clicked

I have a large unordered list of categories for the user to checkoff what category they want their product to be in. Each Parent category has children. I'd like to hide all the children, and when you check the parent category, the children of the category show. I've tried this code and it toggles all the children elements and not just the one in the current li being checked.

jQuery

    $('.wcvendors-pro-dashboard-wrapper ul.product_cat_checklist > li > input[type=checkbox]').change(function()
     {
   if ($(this).is(':checked')) {
      $( ".wcvendors-pro-dashboard-wrapper ul.product_cat_checklist li > ul.children" ).toggle( "slow", function() {
      });

      };
    });

List

<ul class="product_cat_checklist">
    <li id="product_cat-15"><input class="wcv_category_check" value="15" type="checkbox" name="product_cat[]" id="in-product_cat-15" data-parsley-multiple="product_cat">
    <label class="selectit" for="in-product_cat-15">Home Furnishings</label>
        <ul class="children">
        <li id="product_cat-61">
            <input class="wcv_category_check" value="61" type="checkbox" name="product_cat[]" id="in-product_cat-61" data-parsley-multiple="product_cat">
            <label class="selectit" for="in-product_cat-61">Bedroom</label>
        </li>
        <li id="product_cat-63">
            <input class="wcv_category_check" value="63" type="checkbox" name="product_cat[]" id="in-product_cat-63" data-parsley-multiple="product_cat">
            <label class="selectit" for="in-product_cat-63">Children’s Furniture</label>
        </li>
        <li id="product_cat-60">
            <input class="wcv_category_check" value="60" type="checkbox" name="product_cat[]" id="in-product_cat-60" data-parsley-multiple="product_cat">
            <label class="selectit" for="in-product_cat-60">Kitchen &amp; Dining</label>
        </li>
        </ul>
    </li>

    <li id="product_cat-38">
        <input class="wcv_category_check" value="38" type="checkbox" name="product_cat[]" id="in-product_cat-38" data-parsley-multiple="product_cat"> 
        <label class="selectit" for="in-product_cat-38">Arts &amp; Crafts</label>
        <ul class="children">
            <li id="product_cat-53">
                <input class="wcv_category_check" value="53" type="checkbox" name="product_cat[]" id="in-product_cat-53" data-parsley-multiple="product_cat"> 
                <label class="selectit" for="in-product_cat-53">Art Supplies</label>
            </li>
            <li id="product_cat-52">
                <input class="wcv_category_check" value="52" type="checkbox" name="product_cat[]" id="in-product_cat-52" data-parsley-multiple="product_cat"> 
                <label class="selectit" for="in-product_cat-52">Bath &amp; Beauty</label>
            </li>
            <li id="product_cat-46">
                <input class="wcv_category_check" value="46" type="checkbox" name="product_cat[]" id="in-product_cat-46" data-parsley-multiple="product_cat"> 
                <label class="selectit" for="in-product_cat-46">Clothing &amp; Shoes</label>
            </li>
        </ul>
    </li>
</ul>



How dose the click event get registered when you are not clicking the checkbox or using javascript?

So I'm working on a custom checkbox and I'm using an example from W3Schools.
What I can't figure out is how is the click event registered when we are not clicking the checkbox?
As you can see in the image below, the input field is on the right of the label text.

enter image description here

HTML

<label class="container">One
  <input type="checkbox" checked="checked">
  <span class="checkmark"></span>
</label>

CSS

/* Customize the label (the container) */
.container {
  display: block;
  position: relative;
  padding-left: 35px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 22px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Hide the browser's default checkbox */
.container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* When the checkbox is checked, add a blue background */
.container input:checked ~ .checkmark {
  background-color: #2196F3;
}



How to get checkbox selected in ASP.NET MVC from database?

I have this model

public class UserModel
{
   public List<UserModel> Skills { get; set; }
   public int SkillId { get; set; }
   public string SkillName { get; set; }
   public bool IsSelected{ get; set; }
}

In Edit.cshtml

@for (var i = 0; i < Model.Skills.Count; i++)
{
            <div>
                @Html.HiddenFor(x => x.Skills[i].SkillId)
                @Html.CheckBoxFor(x => x.Skills[i].IsSelected, new { htmlAttributes = new { @class = "form-control } })
                @Html.DisplayFor(x => x.Skills[i].SkillName, new { htmlAttributes = new { @class = "form-control" } })
            </div>
}

In database I have saved SkillId. On the basis of skillId, how to get checkbox selected when editing?




Divide sum as a result of checkboxes toggled javascript

I'm having an issue. I have an accumulated sum of gathered donations, ex. 10€. Then I have a number of NGO's that you can choose to donate to. You have the opportunity to toggle on/off which NGO's you would like to support. Either you can choose to donate to all of them which means each NGO will receive 10€ / 3 = 3,33 € each. You can choose two and the allocation is going to be 10 € / 2 = 5€ each etc.

I'm having issues of finding a way to do this in javascript. Could you lead me the right way? Thanks.

My HTML atm:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="Velgørenhed.js"></script>

    <link rel="stylesheet" type="text/css" href="Velgørenhed.css"/>

</head>
<body>

<!-- Tilbage knap  -->
<button id="tilbage" onclick="goBack()">Tilbage</button>

<script>
    function goBack() {
        window.history.back();
    }
</script>


<form action="/action_page.php" method="get">
    <input type="checkbox" name="organisation" value="WHO" checked> Vælg velgørenhedsorgsnisation WHO<br>
    <input type="checkbox" name="organisation" value="Plastic Change" checked> Vælg velgørenhedsorgsnisation Plastic Change<br>
    <input type="checkbox" name="organisation" value="Sea Turtle Conservancy" checked> Vælg velgørenhedsorgsnisation Sea Turtle Conservancy<br>
    <input type="submit" value="Submit">
</form>



<p>y = 5, calculate x = y / 3, and display x:</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
    function myFunction() {
        var y = 5;
        var x = y / 3;
        document.getElementById("demo").innerHTML = x;
    }
</script>






<!-- Log ud knap -->
<button id="logOut" onclick="logOut()">Log ud</button>

<script>
    function logOut() {
        document.location.href = "1logInd.html";
    }
</script>




</body>
</html>



uncheck and check all checkboxes with a button in flask

I have a flask app that has a bunch of checkboxes, some of the pre-checked. I would like to have a button that checks/unchecks all the checkboxes. I realized that I should do it with a javascript function, so I created a file script.js in the static folder and put these functions in it:

$("#uncheck-all").click(function(){
    $("input[type='checkbox']").prop('checked',false);
});


$("#uncheck-all").click(function(){
    $("input[type='checkbox']").prop('checked',true);
})

Then I addressed the file in the template:

<script type="text/javascript" src=""></script>

and added the buttons on the page:

<input type="button" id="uncheck-all" value="UncheckAll"/>
<input type="button" id="check-all" value="CheckAll"/><br>

But unfortunately, none of them work. I would appreciate it if anyone helps me with it.




how can i show the values of checkbox from mysql server

i want it show that it checked , i have columan contain (1s and 0s) so i want 1 is checked and 0 is not but idk how to do that plz help @Override public void onBindViewHolder(MyViewHolder holder, int position) {

    holder.name.setText("Book Name:  " +contacts.get(position).getName());
    holder.email.setText("Book Stand number:  " + contacts.get(position).getEmail());
    holder.country.setText("Shelf number:  " + contacts.get(position).getCountry());
    holder.booknumber.setText("Book number:  " + contacts.get(position).getBooknum());
    holder.TechExists.setChecked(contacts.get(position).getTechnologyExists()==1);

}



@Override
public int getItemCount() {
    return contacts.size();
}

public static class MyViewHolder extends RecyclerView.ViewHolder{
    TextView name,email,country,booknumber ;
    CheckBox TechExists ;
    public MyViewHolder(View itemView) {
        super(itemView);
        name = itemView.findViewById(R.id.name);
        email = itemView.findViewById(R.id.email);
        country = itemView.findViewById(R.id.country);
        booknumber = itemView.findViewById(R.id.booknumber);
        TechExists = (CheckBox) itemView.findViewById(R.id.chkTechExists);
    }
}



mardi 22 octobre 2019

Checkbox values not being updated in tkinter

I'm pretty new to python and trying to create a GUI using tkinter for a program (manipulating csv files). I will have file names in a list, I need checkboxes corresponding to these files which I have accomplished using the below code. The only hurdle now is getting the state of the checkbox into another dict/list which I can use further down the code. Any help would be appreciated. Partial code below. Also getting an error while trying to extract values of the checkboxes in click6()

from tkinter import *

window0 = Tk()

chkstate2 = []
fileNAMES3 = ['a', 'b', 'c'] 
intvar_dict = {}
intvar_dict = dict.fromkeys(intvar_dict, 0)

def click2():
    window7 = Tk()
    window7.title("Choose files to plot")

    for in1c, in2c in enumerate(fileNAMES3[:], start = 0):
        intvar_dict[in2c] = IntVar()
        chk = Checkbutton(window7, text=fileNAMES3[in1c], var=intvar_dict[in2c], onvalue=1)
        chk.grid(column=0, row=in1c)

    def click6():       
        for a,b in enumerate(intvar_dict[:], start=0):
            if intvar_dict[b].get() > 0:
                chkstate2.append(intvar_dict[b])
        window7.destroy()

    btn7 = Button(window7, text="OK",command=click6)
    btn7.grid(column=0, row=in1c+1,padx=10, pady=10)
    btn7.config(height = 2, width = 20 )

btn2 = Button(window0, text="Choose", command=click2)
btn2.grid(column=2, row=7,padx=20, pady=5)

window0.mainloop()



Multiple Dropdown menu with checkbox

I've done this image to explain better Someone can guide me on how to realize a multiple dropdown menu, where the first level items can be selected(maximum one at a time) and every item can be extended to a second menu where the use can do some regulation (solider or toggle button). I've added a photo to explain better what should be. Sorry for my bad english. Thank you very much!

I've tried with bootstrap dropdown but i have some problems with checkbox inside "dropdown-submenu"




Vuetify checkboxes array checks all boxes when list changes

I'm pretty new to both vue and vuetify so there might be a few horrible lines in my code, but I'm really struggling with this one and a bit of help would be nice.

I have an array of checkboxes generated with a v-for loop on an "items" array. This array of checkboxes is attached to a model array just like this example from the vuetify documentation.

It looks like the code below.

The problem is : if I change the items array, even when the model array is still empty, all checkboxes end up checked.

Here is my template :

<div id="app">
  <v-app>
    <v-content>
      <v-container>
        <div>
          <v-list>
            <v-list-item 
               v-for="item in items" :key="item.id"
             >
              <v-checkbox 
                 v-model="model" :label="item.name"  
                          :value="item" 
                          :value-comparator="comparator"
                          ></v-checkbox>
            </v-list-item>
          </v-list>
          <v-btn @click="updateItems">Change elements</v-btn>
        </div>
      </v-container>
    </v-content>
  </v-app>
</div>

and the script


new Vue({
  el: "#app",
  vuetify: new Vuetify(),
  data() {
    return {
      model: [],
      items: [
        {
          id: 1,
          name: "Item1"
        },
        {
          id: 2,
          name: "Item2"
        },
        {
          id: 3,
          name: "Item3"
        },
        {
          id: 4,
          name: "Item4"
        }
      ]
    };
  },
   methods: {
    valueCompare(a, b) {
      return a.id == b.id;
    },
       updateItems() {
            this.items = [
        {
          id: 1,
          name: "Element1"
        },
        {
          id: 2,
          name: "Element2"
        },
        {
          id: 3,
          name: "Element3"
        },
        {
          id: 4,
          name: "Element4"
        }
      ]
    }
   }
});

And a codepen is way easier to understand

I've been struggling with this issue for a while now, if you have any idea, that would be welcome. Thank you !




Change CSS Stylesheet when checkbox is marked

I was trying to create a checkbox in HTML which changes the current stylesheet to another one using JS.

Here is the code I have written:

HTML:

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Normal Title</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link id="pageStyle" rel="stylesheet" href="style.css">
    <script>
        function swapStyleSheet(sheet) {

        if (document.getElementById("lightSwitch").checked == true) {

        document.getElementById("pageStyle").set.Attribute('href', sheet) = "dark.css";

            } 
        else {

        document.getElementById("pageStyle").set.Attribute('href', sheet) = "style.css";

            }
        }
    </script>
</head>
<body>

        <input onclick="swapStyleSheet()" id="lightSwitch" type="checkbox" name="lightSwitch">

</body>

Thanks for clarifying the problem for me.




vue checkbox v-model binding not working properly in the current version

The following code is supposed to list a series of tasks according to their status of completion. It works just fine when I use a 2.5.xx Vue cdn link.

However with the current version's cdn (>= 2.6.0), whenever I check/uncheck a task from either list, the next item on the list is checked/unchecked too, even though it's completed status attribute is not affected (I can see it with the Vue Chrome extension) unless I click on it again.

    <div id="root">
      <h3>Incomplete Tasks</h3>
      <ul>
        <li v-for="task in incompleteTasks">
          <input type="checkbox" v-model="task.completed"> 
        </li>
      </ul>

      <h3>Completed Tasks</h3>
      <ul>
        <li v-for="task in completedTasks">
          <input type="checkbox" v-model="task.completed"> 
        </li>
      </ul>
    </div>

new Vue({
  el: '#root',

  data: {
    tasks: [{
        description: 'Go to the store',
        completed: true
      },
      {
        description: 'Finish screencast',
        completed: false
      },
      {
        description: 'Make donation',
        completed: false
      },
      {
        description: 'Clear inbox',
        completed: false
      },
      {
        description: 'Make dinner',
        completed: false
      },
      {
        description: 'Clean room',
        completed: true
      },
    ]
  },

  computed: {
    completedTasks() {
      return this.tasks.filter(task => task.completed);
    },

    incompleteTasks() {
      return this.tasks.filter(task => !task.completed);
    },
  },
});

Is this a bug? Did something change in how we should use v-model?

Here's a fiddle reproducting the issue using Vue 2.6.10

https://jsfiddle.net/flayshon/fd7mejvo/2/