mercredi 22 mai 2019

Select a node in D3.js using a checkbox change opacity

I'm trying to select a node using a checkbox, and change their opacity but it have being impossible. I have try using a conditional. Does I need something else? Like:

if (typeFilterList.includes(id)) {
node.style("opacity", 0.2);
} else {
node.style("opacity", 2.0);
}

My code is the following:

function cambio(){
d3.selectAll(".filter-btn1").each(function(d){
cb = d3.select(this);
grp = cb.property("value")
if(cb.property("checked")){ 
if (grp === "Azuless") {
alert("Azuless")
node.style("opacity", 0.2);
}
}else{
alert("no chekeado");
node.style("opacity", 2.0); 
}
})
}
d3.selectAll(".filter-btn1").on("change",cambio);
cambio();

Every time I check one of the checkbox the opacity of node change, but it doesn't change.




Change the status of toggle using jquery

I am trying to change the status of toggle switch using jquery but not success. this is the code of jquery

$('#bandwidthcap').checked='false';

and I tried using this way

$('#bandwidthcap').attr('checked','false')

this is the code of html

<input type="checkbox"  name="bandwidthcap" id="bandwidthcap" class="switchery" data-color="primary"/>




mardi 21 mai 2019

jQuery Checkboxs as radio buttons with ability to uncheck all

I have a series of checkboxes that act as radio buttons. These need to stay checkboxes rather than radio buttons, to be consistent with other checkboxes in the same group. The question is what to do when a user wants to uncheck all after making a selection. My solution does not allow for this. Clicking on a selected checkbox simply remains checked.

$(".OverLen").on("click", function()
{
    Current = this.id;
    if($("#"+Current).prop("checked", true))
    {
        $(".OverLen").prop("checked", false);
        $("#"+Current).prop("checked", true);
    }
});




checking one checkbox closes all other checkboxes in HTML/CSS

To list portfolio items on https://khofstadter.info/ I use the idea for collapsible checkboxes from https://bernholdtech.blogspot.com/2013/04/very-simple-pure-css-collapsible-list.html.

How can I uncheck an active/open checkbox by checking another checkbox? I.e. I would like to make sure that only one checkbox is open all the time.

I've tried to use the solutions in related posts on Stackoverflow.

CSS

.collapsibleList li > input + * {
 display: none;
}

.collapsibleList li > input:checked + * {
 display: block;
}

.collapsibleList li > input {
 display: none;
}

.collapsibleList label {
 cursor: pointer;
}

HTML code

<ul class="collapsibleList">
 <li>
  <label for="mylist-node1">Click to open list 1</label>
  <input type="checkbox" id="mylist-node1" />
  <ul>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
  </ul>
 </li>
 <li>
  <label for="mylist-node2">Click to open list 2</label>
  <input type="checkbox" id="mylist-node2" />
  <ul>
   <li>Item 1</li>
   <li>Item 2</li>
   <li>Item 3</li>
  </ul>
 </li>
</ul>

I would ideally like to remain in CSS and HTML, but can go for JS if needed.

Thanks! k




Checking if datagridview already exist in another datagridview before inserting using checkbox

i have two datagridview and i am trying to insert value in datagridview1 to datagridview2 using checkbox on button click.

For i As Integer = DataGridView1.Rows.Count - 1 To 0 Step -1

        Dim c As Boolean
        c = DataGridView1.Rows(i).Cells(0).Value

        If c = True Then
            With DataGridView1.Rows(i)
                DataGridView2.Rows.Insert(0, .Cells(0).Value, .Cells(1).Value, .Cells(2).Value, .Cells(3).Value, .Cells(4).Value, .Cells(5).Value)
            End With
        End If

    Next

My code will insert the data everytime i insert it. I want to prevent inserting the same data on datagridview2. Thank you so much.




Get input type="text" values by checked checkboxes

I'm doing a little project and want to get all input type="text" values if the checkbox is checked. How does it work?


<form name="test" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" target="_blank">
<?php
    foreach ($data['items'] as $key => $value) {
         echo "<label class="Items">
            <input type="checkbox" checked="checked" name="items[]" value="$value">
            <input type="text" value="$value">
        </label>";
    }
?>
</form>

Ive already tried this, but it only returned my checkbox values not my text values.

if(isset($_POST['items'])) {
     $items = $_POST['items'];
}




lundi 20 mai 2019

Tkinter Checkbutton variable doesnt change on second window level

I have a button on a Tkinter window, which leads me to a second Tkinter window with some Checkbuttons. If i click them their assigned variable doesnt change. The second window just by itself works fine.

test2.py

from Tkinter import *
import test

window = Tk()
btn = Button(window, command=test.main)
btn.pack()
window.mainloop()

test.py

from Tkinter import *
from functools import partial

def func(n):
  print var[n].get()


def main():
  window = Tk()
  global var 
  var = [IntVar(), IntVar()]

  i = 0
  ck = Checkbutton(window, variable=var[i], command=partial(func,i))
  ck.grid(row = 0, column = 0)

  i += 1
  ck2 = Checkbutton(window, variable=var[i], command=partial(func,i))
  ck2.grid(row = 1, column = 0)

  window.mainloop()

# main()