jeudi 31 août 2017

How to pass prettycheckable checkbox values into viewmodel to controller

I can't get my checked values to pass to my viewmodel that is being accepted by my controller action method. I'm using the prettycheckable jquery plugin.

$("#HostCreateEvent").prettyCheckable();
<input type="checkbox" name="HostCreateEvent" id="HostCreateEvent" data-label="Event Created" value="@Model.HostCreateEvent" @(Model.HostCreateEvent == true ? "checked" : "") />

Here is my controller and viewmodel

[HttpPost]
    public ActionResult Notification(UserNotificationViewModel viewModel)
    {
        try
        {
            ViewBag.Title = "Account";
            ViewBag.MenuItem = "account";
            ViewBag.UserMenuItem = "notification";

            _yogaProfileService.SaveNotificationInfo(User.Identity.GetUserId(), viewModel);

            TempData["success"] = true;
            TempData["message"] = "Successfully updated notifications";
            return View(viewModel);


        }
        catch (Exception ex)
        {
            _errorService.LogError(ex, Request);
            ModelState.AddModelError("", "Something went wrong updating your notification settings!");
            return View(viewModel);
        }
    }

and my viewmodel

public class UserNotificationViewModel
{
    public bool HostCreateEvent { get; set; }
}




Check at least one checkbox in the form when the form is expanded

I have a form that expands when it is checked. When the form is expanded, there are multiple check boxes - I need to make sure that at least one checkbox is checked at this time. I have the following html/js code that works when none of the checkboxes are selected, but when I select the main checkbox, error goes away. Error should go away when any checkbox is selected in the expanded form.

 $(document).ready(function () {
    $('#checkBtn').click(function() {
      checked = $("input[type=checkbox]:checked").length;

      if(!checked) {
        alert("You must check at least one checkbox.");
        return false;
      }

    });
  });
.inputs {
  display: none;
}

.foo:checked + .inputs {
  display: initial;
}
<script src="http://ift.tt/1q8wkLp"></script>

<form action="foo">
  <input type="checkbox" class="foo"> Pre-designed contour:
  <div class="inputs"> 

    <input type="checkbox" name="contour" value="fiveSeven" id="fiveSeven"> 5x7
    <input type="checkbox"  required id="sixEight"> 6x8
    <input type="checkbox" required id="sixNine"> 6x9
  </div>   
</form>

<input type="button" value="Test Required" id="checkBtn">



mercredi 30 août 2017

Why is this nested JavaScript function running twice?

I've got a long input:selectbox list. The list is essentially a filter that shows/hides information on the page based on what's selected/not selected.

In the list, if something is checked I want the corresponding <div> to show. If something is unchecked I want the corresponding <div> to hide.

Simple enough? Apparently not for me. :(

Code:

$('.ddFilter input:checkbox').off().on('click', function() {

  $('.hideFrequent').slideUp();

  $('input:checkbox:not(:checked)').each(function() {
      $('div.' + $(this).val()).slideUp();
  });

  $('input:checkbox:checked').each(function() {
      $('div.' + $(this).val()).slideDown();
  });
});

The first nested function, $('input:checkbox:not(:checked)'), always runs twice. The first time it runs it hides everything that is not checked. The second time it runs it hides everything.

If that function comes after the :checked function, then no matter how you interact with the list, everything is always hidden. If I put that function first, everything that is unchecked is hidden, then all things are hidden, then the :checked function runs and re-displays the <divs> associated with the checked checkboxes.

What'm I doing wrong?




showing select on check reactjs

I am trying to get a select to show/hide on check but the select just renders and does not disappear nor reappear. I am fairly new to react, so I am sure I am doing something wrong.

export default class TreeTest extends Component {
  constructor() {
    super();

    this.state = {
      checked: [
        '/grantSettingsPermissions/Admin',
        '/grantSettingsPermissions/ContentGroups/AddLocations', 
      ],
      expanded: [
        '/grantSettingsPermissions',
        '/grantSettingsPermissions/ContentGroups',
      ],
    };

    this.onCheck = this.onCheck.bind(this);
    this.onExpand = this.onExpand.bind(this);
    this.handleChange = this.handleChange.bind(this);
  }

  onCheck(checked) {
    console.log(checked);
    this.setState({
      checked,
    });
  }

  onExpand(expanded) {
    this.setState({
      expanded,
    });
  }

  handleChange() {
    this.setState({
      checked: !this.state.checked,
    });
  }

  render() {
    const { checked, expanded } = this.state;
    const content = this.state.checked
    ? <select>
  <option value="test1">test1</option>
  <option value="test2">test2</option>
</select>
      : null;
    return (
            <div>
              { content }
              <CheckboxTree
                  checked={checked}
                  expanded={expanded}
                  nodes={nodes}
                  onCheck={this.onCheck}
                  onExpand={this.onExpand}
                  expandDisabled={true}
                  onChange={ this.handleChange }
              />
          </div>
    );
  }
}

I have a feeling I just need to add stuff to the onCheck function, but I am not entirely sure. Any help would be awesome!




Unchecking a check from an emulated checkbox

I'd like to know how to modify this code to handle unchecking from an emulated checkbox.

First, here's the original input html:

<input type="radio" name="rf538" id="rf538" class="page_checkbox">

And here is the input css for class page_checkbox:

.page_checkbox {
   display: none;
}

After the input html, I have this:

<label for="rf538"><span></span>Pleasures</label>

Here is my css code for the span inside the label:

.page_checkbox+label span {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin: -2px 8px 0px 0px;
    background-color: #ffffff;
    vertical-align: middle;
    cursor: pointer;
    border-radius: 1px;
}

Finally, here is the css code that creates the checkbox and the check:

.page_checkbox:checked+label span:before {
    position: relative;
    left: 3px;
    top: 2px;
    content: '\002714';
    color: #f06000;
    font: 16px/16px Arial, Helvetica, Sans-serif;
}

You can see that there is a CSS for having a checked state but I do not know how to handle for unchecking the span box created.




Is it possible to transform this into kotlin or java code lines without using XML?

This is the XML file that generates the images below, i need to change colors dynamically in my code so I'm trying to reproduce this straight in Kotlin, but I can not play the same properties and behaviors found in XML and i mainly need to change colors.

<item><shape>//selector_1.xml
    <solid android:color="@color/colorPrimary"/>
    <stroke
        android:width="1dp"
        android:color="@android:color/holo_orange_dark" />
    <corners
        android:radius="10dp" />
    <gradient
        android:angle="225"
        android:endColor="@android:color/transparent"
        android:startColor="@android:color/background_light" />

</shape></item>

<item><selector>
    <item android:state_checked="true"><shape>
        <stroke
            android:width="15dp"
            android:color="@android:color/transparent" />
        <corners
            android:radius="5dp" />
        <gradient
            android:angle="135"
            android:endColor="@android:color/transparent"
            android:startColor="#FF1f00f0" />
    </shape></item>
</selector></item>

<CheckBox
    android:id="@+id/chk_1"
    android:layout_width="36dp"
    android:layout_height="36dp"
    android:layout_centerHorizontal="true"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp"
    android:background="@drawable/selector_1"
    android:button="@drawable/selector_1" />

enter image description here

val shape2 = GradientDrawable()
shape2.setSize( 46, 46 )
shape2.setColor( Color.BLUE )
shape2.cornerRadius = 10f
holder?.chkCol1?.buttonDrawable = shape2

I tried in many ways but unfortunately I could not.




How to add a checkbox in Grocery CRUD codeigniter and send the checked records into the database?

I am trying to add checkbox in the default flexigrid theme of grocery CRUD in codeigniter. I have tried using $crud->field_type('yourfield','true_false'); But it did'nt work out. Help me out, thank you.




Grouping checked and Unchecked checkbox rows in jsgrid.

I have a column with checkbox itemTemplate like below and i wanted to group all the checkboxes which are checked and group all the checkboxes which are not checked by some button click in the header row or by sort/filter functionalities.




ng-style and ng-disabled initially evaluate as true even though boolean is false in ng-repeat?

I'm running into a strange problem with ng-style and ng-disabled in the context of an ng-repeat. I have the following template...

        <li ng-repeat="value in currentFacet.values track by $index">
          
          <input type="checkbox" ng-model="options[$index]" ng-true-value="''" ng-checked="value.isActive" ng-disabled="showAll"/>
          <span ng-style="showAll ? {color:'gray'} : {}"></span>
        </li>

Which produces a list of checkboxes. There is a showAll boolean which disables all of these checkboxes.

Initially when the page loads it seems that ng-style and ng-disabled evaluate as if the boolean had been true...even though when I viewed the current status of the boolean (That's why that is in there) it was false.

If I change the boolean to true and then back to false the functionality works as expected. It is only on the initial page-load that this udnesired behavior occurs.




Add value, text and state to array for all checkboxes within a div

I would like to get and add the value, text and state of a checkbox to an array in order to convert to json.

The generated html looks like this.

<div id="utilityMultiSelect" class="col-lg-3">
    <div class="widgetMultiSelect form-control multiselect-checkbox" style="height: auto; border: solid 1px #c0c0c0; display: inline-table; width: 100%;">
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="-127">Heat and steam</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="-26">Diesel</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="-19">Gas</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="-16">Water</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="-10">Energy</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="-1">Electricity</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="1">Natural Gas</label>
        <label style="display: block; !important;" class="multiselect-checkbox-on"><input checked="checked" class="multiSelectCheckBox" name="" type="checkbox" value="8">_Costs</label>
    </div>
</div>

I've got the following so far..

$("#searchForm").on('submit', function () {
        //get checkboxes for div and map to array with value, text and state
        var selectedUtilities = $('#utilityMultiSelect input:checkbox')
            .map(function () {
                return
                //$(this).val()
                //$(this).is(':checked');
            }).get();

I can return the value or state, how do I transform it similar to a selectlistitem with a value, text and selected? Is there a nice way of doing so with jQuery or using underscorejs?




Check if checkbox is checked and disabling button not working

I am trying to disable a button when a checkbox is not checked and enable it again when it's checked.

So to test I added a console log inside the code, but there is no message in my console when I check the checkbox.

My code:

the_terms.click(function() {
            console.log('test');
        if (jQuery(this).is(":checked")) {
            jQuery("#checkoutbtn").removeAttr("disabled");
        } else {
            jQuery("#checkoutbtn").attr("disabled", "disabled");
        }
    });

Then the button and checkbox:

<button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" id="checkoutbtn" onclick="review.save();" disabled="disabled"><span><?php echo $this->__('Place Order') ?></span></button>
<p><input type="checkbox" class="checkbox" id="voorwaarden" style="display:inline;"/><b> Ik ga akkoord met de algemene voorwaarden</b></p>

What's wrong?




How to get objects from ListStore?

I am working on some GWT app. I have two classes: GwtRole and GwtAccessRole. GwtRole are all available roles in application, while GwtAccessRoles are roles which are assigned to selected user via checkbox form panel. When user clicks on button for adding some roles, then checkbox form panel appears with all available roles(GwtRoles are all roles which exist in application). But I want to set that when user clicks on button and checkbox form panel shows, then roles which are already in database to be automatically checked. I have a list of roles which are in database(GwtAccessRoles are roles which are selected in checkbox and stored in db) via RpcProxy method, but I dont know how to get that roles from ListStore. This is my code for checkbox form panel with all available roles:

 CheckBoxSelectionModel<GwtRole> selectionModel = new CheckBoxSelectionModel<GwtRole>();

        configs.add(selectionModel.getColumn());
        RpcProxy<ListLoadResult<GwtRole>> roleUserProxy = new RpcProxy<ListLoadResult<GwtRole>>() {

            @Override
            protected void load(Object loadConfig, AsyncCallback<ListLoadResult<GwtRole>> callback) {
                GWT_ROLE_SERVICE.findAll(currentSession.getSelectedAccount().getId(),
                        callback);
            }
        };

        BaseListLoader<ListLoadResult<GwtRole>> roleLoader = new BaseListLoader<ListLoadResult<GwtRole>>(roleUserProxy);
        roleLoader.load();
        ListStore<GwtRole> roleStore = new ListStore<GwtRole>(roleLoader);

        aa = new CheckBoxListView<GwtRole>() {

            @Override
            protected GwtRole prepareData(GwtRole model) {
                String name = model.getName();
                model.set("name", name);
                return model;
            };
        };
         aa.setStore(roleStore);
         aa.setDisplayProperty("name");

roleFormPanel.add(aa);

        bodyPanel.add(roleFormPanel);

and when user click on button, checkbox form panel with names of all available roles appears. This is my method for finding all roles which are in database already(those which are selected last time):

     RpcProxy<PagingLoadResult<GwtAccessRole>> proxy = new RpcProxy<PagingLoadResult<GwtAccessRole>>() {

                @Override
                protected void load(Object loadConfig, AsyncCallback<PagingLoadResult<GwtAccessRole>> callback) {
                    GWT_ACCESS_ROLE_SERVICE.findByUserId((PagingLoadConfig) loadConfig, currentSession.getSelectedAccount().getId(), userId, callback);

                }
            };
            BasePagingLoader<PagingLoadResult<GwtAccessRole>> loader = new BasePagingLoader<PagingLoadResult<GwtAccessRole>>(proxy);
            loader.load();
 ListStore<GwtAccessRole> accessRoleStore = new ListStore<GwtAccessRole>(loader);

I dont know how to get objects from this accessRoleStore to set that all items(from all available roles) which have same id like items from this list to be checked automatically. I am sure that this method gives me real values, because I tested it(I changed that checkbox form panel shows me roles from this method and its all ok) but when I try to get values nothing happens. I found that I should do that with accessRoleStore.getModels() but that gives me 0. Does someone have idea how to get list of objects from those two listStores?




How to check some of the checkbox inside multiple checkbox list using Selenium in c#

I am working on Automation Project, there are multiple checkboxes and they don't have any ID.

CheckBox look like,

enter image description here

and i want to check Level 3 A and Level 1 B checkBox.

Thanks in Advance.




Dynamic checkbox from list with Thymeleaf

I try to save the values from dynamically created checkboxes:

<div>
    <ul>
       <li th:each="item, stat : *{users}">
         <input type="checkbox" th:field="*{users[__${stat.index}__]}" th:value="${item}" />
         <label th:text="${item}"></label>
      </li>
   </ul>
</div>

The controller provides the String items as follwing:

public List<String> getUsers() {
    return users;
}

And the setter for the Strings is:

public void setUsers(final String[] users) {
    for (final String string : users) {
        System.out.println(string);
    }
}

The values are correct shown in the html page. But when i click save button, and the setter is called, the values are empty. What can i do, where is the problem? Any help would appreciate.




Checkboxlist value from table header database

example i have student table like this

| Nama | NIM | Jurusan |
|value | value | value |
|value | value | value |
|value | value | value |

can i set my checkbox list to my table header name (*Nama,Nim,Jurusan)

Sorry my english bad




mardi 29 août 2017

Display check boxes for all the items on a long click in a listview

How to display the check boxes for all the items on long click in a listview?

I tried adding the check box at the end of listview but it is displaying only for one item

thanks




How to call checkbox id that id value is set dynamically

I have call data from mysql and set checkbox id dynamically with php

<?php
    if (isset($sls_data)) {
       foreach ($sls_data as $data) {
?>          
       <div class="checkbox col-md-3 col-sm-2 col-xs-3">                                                                
          <label class="control-label">
              <input type="checkbox" name="<?= $data->SLSGROUP ?>" id="<?= 
               $data->SLSGROUP ?>" value="true">
               <?= $data->SLSGROUP ?>
          </label>
       </div>
   <?php
      }
    }
 ?>

How can I call checkbox id from ajax function.




Using Ionic Checkbox for To-Do Ionic app

I was wondering if it were possible to use a

<ion-item>
  <ion-label>Item1</ion-label>
  <ion-checkbox [(ngModel)]="item"></ion-checkbox>
</ion-item>

to create a to-do app where you check the ion checkbox and then press a submit button and the item is moved from the "to-do" list to a "completed list." These lists would be on the same page as so:

enter image description here




How to disable unchecked checkbox in tree tableview column in Javafx

I have a treetable column, to which I am adding checkbox as below

isPrimary.setCellFactory( new Callback, TreeTableCell>() { @Override public TreeTableCell call(TreeTableColumn param) { return new LiveCheckBoxTreeTableCell(); } });

I am writing my own checkbox as below

public class LiveCheckBoxTreeTableCell extends TreeTableCell{ private final CheckBox checkBox = new CheckBox(); private ObservableList selectedCheckBoxes = FXCollections.observableArrayList(); private ObservableList unselectedCheckBoxes = FXCollections.observableArrayList();

@Override
    public void updateItem(Boolean item, boolean empty) {
        super.updateItem(item, empty);

        if (empty) {
            setGraphic(null);
        } else{

            setGraphic(checkBox);
             if (checkBox.isSelected()) {
                 selectedCheckBoxes.add(checkBox);
             } else {
                 unselectedCheckBoxes.add(checkBox);
             }
            checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {
                  @Override
                  public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2) {
                      if (aBoolean2) {
                            unselectedCheckBoxes.remove(checkBox);
                            selectedCheckBoxes.add(checkBox);
                        } else {
                            selectedCheckBoxes.remove(checkBox);
                            unselectedCheckBoxes.add(checkBox);
                        }

                  }
                });


        }
    }
}

When I check one checkbox other checkbox in the isPrimary column should be disabled. But the Checkbox I check and uncheck will get disabled.Others will remain enabled. Any Javafx please help me to disable unchecked checkbox and enable all checkbox when I uncheck any checked checkbox.




ng-show not triggered when input checkbox selected via javascript

I have an html page where clicking on a checkbox causes a new section of the page to become visible. The HTML looks like this:

            <input id="formcheck" ng-model="collapseform" type="checkbox">Fill in the Test Form         
            <div id="mainformdiv" class="wizard-div" ng-show="collapseform">                
                    <div>                           
                        <div class="main-block">    
                                ...and so on
                        </div>
                    </div>
            </div>

This part works fine - by default that part of the page is hidden, and when I select the checkbox, the rest of the page appears. When I deselect it, the rest of the page is hidden again.

Further down on that same page there is a table, and when you select a node in that table it calls a controller function that causes some internal values to be set - this part works as well, so the controller seems to be set up correctly and all the functions can be called.

The problem I'm seeing is this: I want to add a bit to the controller function that gets called when the table node is selected, and what I want it to do is, in addition to setting the internal values (which it does correctly), also check the checkbox, and cause the hidden part of the page to be displayed in response. I thought if I checked the checkbox through the javascript that would accomplish this, so I added this to the internal value setting function:

        if (document.getElementById("formcheck").checked == false) {
            document.getElementById("formcheck").checked = true;
        }

That kind of works - the checkbox does get checked off when that piece of code is called, however, unlike when I click the checkbox with a mouse, it does not seem to trigger the ng-show, and so the hidden part of the page is not made visible. Is there something else I need to do in order to make this work?

Thanks!




Hide Content With MS Word Checkboxes

I would like to check a content control checkbox and have it only show some text content when the box is checked.

I have attempted to do this with IF statements and bookmarks, but I have not been able to get it to do what I want.

Even just trying to reference the checkbox in Word is proving to be difficult:

{IF check = ☒ "CHECKED" "UNCHECKED"} 

Where the title and tag of the checkbox are 'check', and the ☒ is a content control checkbox.

Any steering in the right direction would be helpful! I am trying to avoid using VBA.




how do i create a toast that reads off the checked check boxes in a list with an adapter

ive created a list using a custom adapter the list has checkboxes and i have a button at the bottom of the main activity. what im hoping to achieve is that when i press the button a toast will appear stating all the items that have been checked.i know i need to create a list array but im not sure how to use the checked checkboxes into deciphering what goes into the array list. thanks for any help will be much appreciated. heres the java code ive got so far.

public class MainActivity extends AppCompatActivity {
ListView lv;
boolean [] checkBoxes;
int boxIndex = 0;
Button b;

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.activity_main);
    String[] s = {"Ham and pineapple", "Supreme", "Seafood",
            "Italian", "Meat lovers", "cheese"};
    checkBoxes = new boolean[s.length];


    CustomAdapter adapter = new CustomAdapter(this, s);
    lv = (ListView) findViewById(R.id.listView);
    b = (Button) findViewById(R.id.button);
    lv.setAdapter(adapter);

    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
           String item = (String)lv.getAdapter().getItem(position);
          Toast.makeText(getApplicationContext(), item + " is selected", Toast.LENGTH_LONG).show();

          CheckBox cb = (CheckBox) lv.findViewById(R.id.checkBox);
          boxIndex = position;
          cb.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                  checkBoxes[boxIndex] = true;
              }
          });

      }

  });

public static class CustomAdapter extends ArrayAdapter<String>
{
   private final Context context;
    private final String[] s;

    public CustomAdapter(Context context, String[] s) {
        super(context, R.layout.rowlayout, s);
        this.context = context;
        this.s = s;
    }
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(R.layout.rowlayout, parent, false);

        TextView textView = (TextView) rowView.findViewById(R.id.list_item);
        ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
        textView.setText(s[position]);
        String t = s[position];
        if (t.startsWith("Supreme") || t.startsWith("Seafood")) {
            imageView.setImageResource(R.drawable.star);
        } else {
            imageView.setImageResource(R.drawable.pizza);
        }

        return rowView;
    }
  }
}




AngularJS - Form for dynamic created checkbox

I'm Creating Multiple checkbox using ng-repeat. How to validate such form if any one of checkbox is checked using form validation?

<div class="checkbox" ng-repeat="nereg in northeastRegion track by $index" ng-click="nereg.selected = !nereg.selected">
  <input type="checkbox" ng-checked="nereg.selected" >
  <label for=""></label>
</div>

JS

$scope.northeastRegion = [{
        title: 'New England',
        selected: false
      },
      {
        title: 'New York Metro',
        selected: false
      },
      {
        title: 'Philly Tri-State',
        selected: false
      },
      {
        title: 'Upstate New York',
        selected: false
      },
      {
        title: 'Washignton',
        selected: false
      }
    ];




PDO multiple checkboxs inserting or delete

I need help to link between three tables by checkboxe:

features table ( id, title, sulg )

posts table (id, title, slug, added )

posts_features ( fea_id, post_id )

<input type="checkbox" name="featuresid[]" value="$features->id">

If checked ( insert ) if not exist.

foreach ($_POST['featuresid'] as $choice) {
$sql = $dbh->prepare("INSERT INTO posts_features (fea_id, post_id) VALUES ($choice, $id)");
$sql->execute();
}

if un-checked ( delete ) from posts_features

$sql = $dbh->prepare("delete form posts_features where ........

Thanks in advance.




Glyphicons no longer supported in Bootstrap 4

I've read, from official docs, that Glyphicons were dropped from Bootstrap 4.

Today, in my searching for implementing checbox button, I've found one snippet that I appreciate very much:

Snippet for Checkbox 3.0

The problem is that this version is for Bootstrap 3.0, where Glyph were supported yet.

So I've 2 question:

  1. Wich is a good alternative to Glyphicons? Or there is a way to use them yet?
  2. How I may change the html and js snippet above to make it working wuth Bootstrap 4?



How to pass html table checked rows data to bootstrap modal box using jQuery?

I have a HTML table with checkbox in first cell of each row. After selecting the row by checking the checkbox and then click on Bulk Inventory Transfers button I want all selected rows with its first 4 cells data(ignoring the checkbox cell) should popup in Bootstrap Modal.

HTML Table Image




Bootstrap Checkbox inside jQuery Data Table

I have to add a column in my jquery Data Table, where I must put checkbox buttons. Cause I'm using Bootstrap, I want use it instead classic html checkbox, so I've searched on the web how I can perform my task. I've founded 2 options that are good for me and my boss, but I have some troubles.

The first one is this: Bootstrap 4 Button Checkbox

and I've tried to adapt to my situation. So, in my data table file I've putted:

//This function is used to implement the check all option.
$('[data-toggle="buttons"] .btn').on('click', function () {
    // toggle style
    $(this).toggleClass('btn-success btn-danger active');

    // toggle checkbox
    var $chk = $(this).find('[type=checkbox]');
    $chk.prop('checked',!$chk.prop('checked'));

    return false;
});

BEFORE the table; and inside the data table I've putted:

{
   "data":   null,
   "render": function ( data, type, full, meta ) {
                return '<div data-toggle="buttons">
                   <label class="btn btn-block btn-success active">
                   <input type="checkbox" name="select" checked autocomplete="off">Select
                   </label>';
            }
}

Here the problems are 2: first, according with the link, on a click event a button may change from green to red and this does not happen; second, I'm able to select only one checkbox. For example, if I have 4 row and I want select 2 checkbox, I cannot; if I select one and then another, the previous is deselected.

The second way is: jQuery Checkbox Button

Here I've tried to put the code of JS section in an external file and import this in the one with table header, togheter with bootstrap/fonts for the gliph icons; then I've putted only one button of the above link, this:

<span class="button-checkbox">
        <button type="button" class="btn" data-color="primary">Checked</button>
        <input type="checkbox" class="hidden" checked />
    </span> 

inside data table file (on {data: null, render: function()}), but here also I have 2 problems: the button is withe, without glyphs and again, select a new button deselect the previous one. I've noticed that this snippet is for Bootstrap 3; changes are requested to adapt to Bootstrap 4?

In the end: what are my errors?




Checkbox not completing completing function html javascript

I have multiple check boxes in my webpage. Each checkbox runs a javascript function called "adds". This works when you click the box manually.

I have another type of checkbox which checks all the check boxes in that div, but when this is checked it does not run the function "adds" on the checkboxes it checks.

Does anyone know why?

Check all in div function:

<script type="text/javascript" language="javascript">
function checkCheckboxes( id, pID ){
$('#'+pID).find(':checkbox').each(function(){
jQuery(this).prop('checked', $('#' + id).is(':checked'));
});  
}
</script>

Adds Function:

<script type="text/javascript" language="javascript">
function adds(id) {

var value = $(id).val()

    jQuery.ajax({
        url: "selection_update.php",
        data: {"value": value},
        type: "POST",
        dataType: 'json',
            success:function(responce){
            $("#check").html(responce);
        }
    });
}
</script>




how to store selected checkbox values in ArrayList

I want to store selected checkbox values in ArrayList. There is five checkbox if I select three then they will store on ArrayList. I used String []ad = new String[5]; is it write on not to store the value of checkbox

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

CheckBox android, java, python, php, unity3D;
Button submitButton;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    android = (CheckBox) findViewById(R.id.androidCheckBox);
    android.setOnClickListener(this);
    java = (CheckBox) findViewById(R.id.javaCheckBox);
    java.setOnClickListener(this);
    python = (CheckBox) findViewById(R.id.pythonCheckBox);
    python.setOnClickListener(this);
    php = (CheckBox) findViewById(R.id.phpCheckBox);
    php.setOnClickListener(this);
    unity3D = (CheckBox) findViewById(R.id.unityCheckBox);
    unity3D.setOnClickListener(this);

    submitButton = (Button) findViewById(R.id.submitButton);
    submitButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
        }
    });

}

@Override
public void onClick(View view) {

I create one Array String for storing selected values.

    String []ad = new String[5];

Switch Case condition for onClick in checkbox

    switch (view.getId()) {
        case R.id.androidCheckBox:
            if (android.isChecked()) {
                ad[0] = (String) android.getText();
                Toast.makeText(getApplicationContext(), ad[0], Toast.LENGTH_LONG).show();
                Log.e("Android*********",ad[0]);
            }
            break;

        case R.id.javaCheckBox:
            if (java.isChecked()) {
                ad[1] = (String) java.getText();
                Toast.makeText(getApplicationContext(), ad[1], Toast.LENGTH_LONG).show();
                Log.e("Java*********", ad[1]);
            }
            break;

        case R.id.phpCheckBox:
            if (php.isChecked()) {
                ad[2] = (String) php.getText();
                Toast.makeText(getApplicationContext(), ad[2], Toast.LENGTH_LONG).show();
                Log.e("PHP*********", ad[2]);
            }
            break;

        case R.id.pythonCheckBox:
            if (python.isChecked()){
                ad[3] = (String) python.getText();
                Toast.makeText(getApplicationContext(), ad[3], Toast.LENGTH_LONG).show();
                Log.e("Java*********",ad[3]);
            }
            break;

        case R.id.unityCheckBox:
            if (unity3D.isChecked()){
                ad[4] = (String) unity3D.getText();
                Toast.makeText(getApplicationContext(), ad[4], Toast.LENGTH_LONG).show();
                Log.e("Java*********",ad[4]);
            }
            break;
    }
}




Uncheck Select All Checkbox when one checkbox is Unchecked C# in windows form

I have a checkbox when you click on it it select all checkbox the problem here that when unchecked any check box checked didn't remove from select all I tried this code:

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
    if (checkBox1.Checked == false) 
        checkBox9.Checked = false;
}

but when i checked any check box it remove all checkbox i want to unchecked select all only not all checkbox




Error in adding Checked Changed Event to a checkbox- which is added dynamically to a gridview in asp.net application using c#

This is my code

    foreach (GridViewRow row in GridView1.Rows)
        {
            dataReader.Read();
            if (row.RowType == DataControlRowType.DataRow)
            {
                CheckBox cb = new CheckBox();
                cb.ID = "chkbox";
                if (int.Parse(dataReader[0].ToString()) == 0)
                    cb.Checked = false;
                else
                    cb.Checked = true;
                cb.CheckedChanged += new EventHandler(chkBoxChange);
                row.Cells[4].Controls.Add(cb);

            }
        }

But even though I had wriiten

       cb.CheckedChanged += new EventHandler(chkBoxChange);

the function

    public void chkBoxChange(object sender, EventArgs e){                   
    }

is not invoking when i checked the checkbox.

Please help me...




unchecked selectall checkbox when one checkbox is unchecked C# Win Form [on hold]

I have a checkbox when you click on it it select all checkbox the problem here that when unchecked any check box checked didn't remove from select all I tried this code:

 if (checkBox1.Checked == false) 
           checkBox9.Checked = false;

but when i checked any check box it remove all checkbox i want to unchecked select all only not all checkbox




how to find range inside checkbox

I have a column named weight in my table accounts. i need to fetch the values from this column like,

when the user clicks weight from 40 - 100, It need to display all the persons with weight in between 40 and 100.

This is my html code,

<div class="float-right span35">
    <form class="list-wrapper search-form" method="get" action="/index.php">
        <div class="list-header">
            Talent Search
        </div>
                <h4 style="margin-left: 10px; color: gray;">Weight</h4>
                <fieldset id="weight">
                    <input type="checkbox" name="weight" value="1" />Below 40<br>
                    <input type="checkbox" name="weight" value="2" />40-70<br>
                    <input type="checkbox" name="weight" value="3" />70-100<br>
                    <input type="checkbox" name="weight" value="4" />Above 100<br>
                </fieldset>
                <br/>
                <input style="margin-left: 10px" type="submit" name="submit" value="search"/><br><br>
                <input type="hidden" name="tab1" value="search">
        </form>
</div>

This is my php code,

if(isset($_GET['submit'])){


    $weight = ($_GET['weight'])? $escapeObj->stringEscape($_GET['weight']): NULL;

    $sql = "SELECT id FROM `".DB_ACCOUNTS."` WHERE `id` IS NOT NULL ";

    if(is_numeric($weight) && $weight != NULL){
        $sql .= "AND `weight` IN (".$weight.")"; 
        $is_weight = true;
    }

    $sql .= " ORDER BY `id` ASC";

    }
    if($is_weight){
        $themeData['weight_'.$weight] = 'checked';
    }

    $query = $conn->query($sql);
    if($query->num_rows > 0){
            while($fetch = $query->fetch_array(MYSQLI_ASSOC)){
                $get[] = $fetch['id'];
            }

            $i = 0;
            $listResults = '';

            $themeData['page_title'] = "Advanced Search - ".$lang['search_result_header_label']; 
            foreach($get as $row){
                $timelineObj = new \SocialKit\User();
                $timelineObj->setId($row);
                $timeline = $timelineObj->getRows();

                $themeData['list_search_id'] = $timeline['id'];
                $themeData['list_search_url']   = $timeline['url'];
                $themeData['list_search_username'] = $timeline['username'];
                $themeData['list_search_name'] = $timeline['name'];
                $themeData['list_search_thumbnail_url'] = $timeline['thumbnail_url'];

                $themeData['list_search_button'] = $timelineObj->getFollowButton();

                $listResults .= \SocialKit\UI::view('search/list-each');
                $i++;
            }
            $themeData['list_search_results'] = $listResults; 

    }

}

This code is almost working for an single weight from table. But I need to create a range in between the checkbox values as i mentioned in the code. Do i need to update the code.




PHP For loop with checkboxes not giving expected output

I am getting some unexpected output from the following code and can't figure out what the problem is.

   <?
    if (isset($_POST['submit'])) {
    echo "<pre>";
    print_r($_POST);
    exit;
    }
    echo "<form action='test1.php' method='post'>";
    for ($i=0;$i < 10;$i++) {
    echo "<input type='text' value='$i' name='field[]'>";
    echo "<input type='hidden' name='cbox[]' value='0'>";
    echo "<input type='checkbox' value='1' name='cbox[]'><br>";
    }
    echo "<br><input type='submit' name='submit' value='go'>";
    ?>

If I run this, check on say number 4 and 6, I get this output:

Array
(
    [field] => Array
        (
            [0] => 0
            [1] => 1
            [2] => 2
            [3] => 3
            [4] => 4
            [5] => 5
            [6] => 6
            [7] => 7
            [8] => 8
            [9] => 9
        )

    [cbox] => Array
        (
            [0] => 0
            [1] => 0
            [2] => 0
            [3] => 0
            [4] => 0
            [5] => 1
            [6] => 0
            [7] => 0
            [8] => 1
            [9] => 0
            [10] => 0
            [11] => 0
        )

    [submit] => go
)

Why is cbox not giving me a result of 1 next to the 4 and 6 as I would expect it?




lundi 28 août 2017

Primng: How to hide/remove checkbox from p-table header

I used primeng p-table for multiple selection grid. I have have requirement to select multiple row by clicking on each row checkbox. I have to hide/remove checkbox from ptable header.

Can I get solution for this. I have tried changing css styles but couldn't able to hide checkbox in header of ptable. thanks in advance.




how do change html checkbox state in javascript?

html source :

'<div class="checkbox">' +
    '<label for="sn-checkbox-open-in-new-window">' +
    '<input type="checkbox" id="sn-checkbox-open-in-new-window" checked />' + lang.link.openInNewWindow +
    '</label>' +
    '</div>';

i find input checkout object this here.

var $openInNewWindow = self.$dialog.find('input[type=checkbox][id=sn-checkbox-open-in-new-window]');

var isChecked = linkInfo.isNewWindow !== undefined ?
        linkInfo.isNewWindow : context.options.linkTargetBlank;

    $openInNewWindow.prop('checked', isChecked);

When I do this, the checkbox does not change properly. The box is not painted or checked.

so

$openInNewWindow.on('click', function(event) {
        $openInNewWindow.val('checked').val(false);
        console.log($openInNewWindow.val('checked'));
        //$openInNewWindow.prop(':checked', !$openInNewWindow.prop(':checked'));
        //console.log($openInNewWindow.prop(':checked'));
      });

I changed the state when I clicked force, but it does not change.

how do change html checkbox state in javascript?

i think rendering block.

help me plz




How to create persist function on checkbox if data is present

I have seen many checkbox examples, but not this one.

I need a checkbox to remain checked if data is present in specific <input> fields. So it would need to be something that is constantly checking field status.

Basic checkbox:

<input class="checkbox" type="checkbox" unchecked onclick="shipping()"/>

It calls a function that removes a <div> and adds another. There is a back button on that new div that will remove/add as well. When the users are back to orig page, if they entered data in that shipping <div> the check box would be checked.

This is a PHP page so I am comfortable using javascript, jQuery or PHP. Just looking for the most reliable way.




Dynamically created CheckBoxs event fires on second click not first

I have created CheckBoxs dynamically in GridView but the CheckedChanged event fires when I click the twice.

Where I'am wrong?

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
    // check if it's not a header and footer
    if (e.Row.RowType == DataControlRowType.Row)
    {
        CheckBox chk = new CheckBox();

        chk.AutoPostBack = true;

        // add checked changed event to checkboxes
        chk.CheckedChanged += new EventHandler(chk_CheckedChanged);

        e.Row.Cells[1].Controls.Add(chk); // add checkbox to second column
    }
}




Multiple Select Checkboxes

My app has two primary user roles:

Staff are university employees who fill out Referral Requests with patient details to be sent to Clinicians

Clinicians are private physicians who receive the referral request if they match the criteria detailed by the Staff user.

A Referral Request is basically a form where the Staff details the patient and their needs.

As part of this form, I want to collect information about a patient's gender identity.

I've created a model called Gender and associated genders table and then filled it in with data using seeds.

["Female", "Male", "Non-binary", "Queer", "Transgender", "Not Specified"].each do |g|

Gender.create!(name: g,
                  created_at: Time.zone.now,
                  updated_at: Time.zone.now)

I originally built the form input for gender this way, with patient_gender_id being an integer column in the referral_requests table and genders displayed as a dropdown.

  Patient's Gender Identification
    <%= collection_select( :referral_request, :patient_gender_id, Gender.all, :id, :name, prompt: true) %>

I want to change this to allow the user to select multiple gender options rather than a single one and to use checkboxes instead of a dropdown.

I know I'll need to change my controller among other things, but I keep getting errors when I try:

def referral_request_params
    params.require(:referral_request).permit(:content, :patient_gender_id, 
        :preferred_gender_id, concern_ids: [], insurance_ids: [])

end

I used this migration to try to change the patient_gender_id field to an array of integers, but I'm not sure it worked b/c I don't see anything in my schema file that would indicate that the field is now an array.

  def change
     change_column :referral_requests, :patient_gender_id, :integer, array: true, default: []
  end
end

-How do I change the form, the controller, and if necessary, the schema to accommodate multiple gender selections with checkboxes?

Any help would be greatly appreciated!




Struts- About saving checkboxes when following a link

I'm working on a jsp containing some checkboxes. My jsp is linked to a form (called SuiviTransfertForm), and this form has an attribute called checkboxUID, which is an array containing the ids of my checked checkboxes.

private String[] checkboxUID = {};

This attribute is mapped with the checkboxes of my jsp like this :

<html-el:multibox name="suiviTransfertForm" property="checkboxUID"/>

I would like to follow a link on this jsp and get the content of checkboxUID when I'm on the next page.

On the next page, I'm getting back my form like this :

SuiviTransfertForm suiviTransfertForm = (SuiviTransfertForm) form;

The problem is that checkboxUID is correctly filled if I stay on the same page, but always empty when I'm changing page. I can't find a way to achieve this.

Many thanks for your help !




Checkbox causes incorrect height on parent element

I am trying so solve a problem that causes me and my colleagues a splitting headache. Even though we've been provided a painkiller each we continue to be baffled by the way Google Chrome renders a checkbox in a container that has a font-size of 10pt.

The problem

Google Chrome seems to render some extra space around a checkbox element that I cannot seem to get rid of. The checkbox and its parent element must be 15 pixels tall. Setting the font-size of the parent element to 10pt causes that parent element to be 16 pixels in height.

An example

Take a look at the snippet below.

I have yet to find out (or understand) what causes the checkbox element to render as 15 pixels tall but effectively making its parent element 16 pixels tall.

td,
th
{
    padding: 0;
    font-size:   10pt;
}

input[type=checkbox]
{
    height: 15px;
    border: none;
    padding: 0;
    margin: 0;
}
<table width="100%" class="data">
    <tr>
        <th>Label 1</th>
        <td>Value 1</td>
    </tr>
    <tr>
        <th>Checkbox 2</th>
        <td><input type="checkbox" disabled="disabled" /></td>
    </tr>
    <tr>
        <th>Label 3</th>
        <td><input type="checkbox" disabled="disabled" checked="checked" /></td>
    </tr>
</table>

Exchanging the table for a div, a p or any other container also results in an incorrect height for that container.

Possible solution?

Setting the checkbox height to 14px makes the parent row 15 pixels tall. But then the checkbox itself does not meet the designer's requirements and thus this solution will not be accepted. Any workarounds?




Make the checkbox behave with radiobutton

Make the checkbox behave like a radiobutton, allowing the checkbox to be deselected. And my select is also part and works the same as the checkbox if the value is greater than 0 the checkbox deselects, if you select a checkbox the select gets 0.

I have such a code in knockoutJS:

   var InternalAuditRecordTopic = function (data) {
                var self = this;
        self.InternalAuditRecordTopicID = ko.observable(data.InternalAuditRecordTopicID);
        self.InternalAuditRecordID = ko.observable(data.InternalAuditRecordID);
        self.Name = ko.observable(data.Name);
        self.Order = ko.observable(data.Order);
        self.Request = ko.observable(data.Request);
        self.NonComformityType = ko.observable(data.NonComformityType);
        self.Comformity = ko.observable(parseInt(data.Comformity));
        self.OM = ko.observable(parseInt(data.OM));
        self.Observation = ko.observable(data.Observation);
        self.Evidences = ko.observable(data.Evidences);          

        self.startPlaceHolders = function () {
            startPlaceHolders();
        };

    };


.....

        ko.cleanNode($("form#internalAuditRecordRegisterForm"));
        var viewModel = new InternalAuditRecord(@Html.Raw(Model.ToJson()));
        ko.applyBindings(viewModel, document.getElementById("internalAuditRecordRegisterForm"));

And in html:

section class="internalAuditRecordTopicDetail with-margin" data-
index="${$index}">
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].Request" value="${Request}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].Name" value="${Name}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].Comformity" value="${Comformity}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].NonComformityType" value="${NonComformityType}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].OM" value="${OM}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].Observation" value="${Observation}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].Evidences" value="${Evidences}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].InternalAuditRecordID" value="${InternalAuditRecordID}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].InternalAuditRecordTopicID" value="${InternalAuditRecordTopicID}" />
            <input type="hidden" name="InternalAuditRecordTopics[${$index}].Order" value="${$index}" />
            <fieldset class="grey-bg relative internalAuditRecordTopic">
                <ul class="mini-menu visible">
                    
                    
                    <li>@Html.UpIcon(null, new { data_bind = "click: $parent.upInternalAuditRecordTopic", @Title = "Subir Item" })</li>
                    
                    
                    <li>@Html.DownIcon(null, new { data_bind = "click: $parent.downInternalAuditRecordTopic", @Title = "Descer Item" })</li>
                    
                    
                    <li>@Html.DeleteIcon(null, new { @Title = "Remover Item", data_bind = "click: $parent.removeInternalAuditRecordTopic" })</li>
                </ul>
                <legend>
                    @*<a href="#" data-bind="text: Name"></a>*@
                    <span>
                        <input type="text" style="width:300px;" class="internalAuditRecordTopicRequest" placeholder="Requisito" data-bind="value:Request" /> 
                    </span>
                </legend>
                <table class="tg" data-id="${$index}">
                    <tr>
                        <td class="tg-yw4l" align="right"><span class="label" style="color:black">Registros da Auditoria: </span></td>
                        <td><span><textarea cols="65" rows="10" style="width:400px;" class="internalAuditRecordTopicName" placeholder="Nome do tópico" data-bind="value:Name" /></span></td>
                    </tr>
                    <tr>
                        <td class="tg-yw4l" align="right"><span for="active" class="label" style="color:black">Comforme: </span></td>
                        <td><input type="checkbox" value="1"  data-bind="checked:Comformity,isSelectedComformity:" class="float-left" /></td>
                    </tr>                   
                    <tr>
                        <td class="tg-yw4l" align="right"><span for="active" class="label" style="color:black">Oportunidade de Melhoria: </span></td>
                        <td><input type="checkbox" value="1" data-bind="checked:OM, isSelectedOM:" class="float-left"/></td>
                    </tr>
                    <tr>
                        <td class="tg-yw4l" align="right"><span class="label" style="color:black">Não Conformidade: </span></td>
                        <td class="tg-yw4l">
                            <span id="span_finished">
                                <select data-bind="value: NonComformityType" id="NonComformityType">
                                    <option value="0" selected>Escolher</option>
                                    <option value="2">Maior</option>
                                    <option value="1">Menor</option>
                                </select>
                            </span>
                        </td>
                    </tr>
                    <tr>
                        <td class="tg-yw4l" align="right"><span class="label" style="color:black">Observações: </span></td>
                        <td><textarea cols="65" rows="10" style="width:400px;" class="internalAuditRecordTopicObservation" placeholder="Observações" data-bind="value:Observation" /></td>
                    </tr>
                    <tr>
                        <td class="tg-yw4l" align="right"><span class="label" style="color:black">Evidências: </span></td>
                        <td><textarea cols="65" rows="10" style="width:400px;" class="internalAuditRecordTopicEvidences" placeholder="Evidências" data-bind="value:Evidences"  id="Evidences" /></td>
                    </tr>
                </table>

What I've already tried:

ko.bindingHandlers.isSelectedOM = {
                init: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
                    if ($(element).is(':checked')) {
                        $(element).closest('table').find(':checkbox').prop('checked', false);
                    }
                },
                update: function (element, valueAccessor, allBindings, viewModel, bindingContext) {
                    if ($(element).is(':checked')) {
         $(element).closest('table').find(':checkbox').prop('checked', false);
                    $(element).closest('table').find('select').prop('value', 0);

                    }
                }
            };




Select checkboxes in a row [on hold]

I need a script that will run on click and check if 4 checkboxes are selected. The important thing that checkboxes must be selected in a row, the order I select them doesn't matter they just must be in a row like: 4,5,6,7 or: 7,8,9,10 and so on. Not sure if this piece of code example will come in handy:

<ul id="checkbox-list">
   <li><input type="checkbox">1</li>
   <li><input type="checkbox">2</li>
   <li><input type="checkbox">3</li>
   <li><input type="checkbox">4</li>
   <li><input type="checkbox">5</li>
   <li><input type="checkbox">6</li>
   <li><input type="checkbox">7</li>
   <li><input type="checkbox">8</li>
   <li><input type="checkbox">9</li>
   <li><input type="checkbox">10</li>
</ul>

<button id="checking">Check</button>

Thanks




How to count number of checkboxes selected from Telerik ASP MVC Grid cell

I'm using Telerik ASP.Net MVC Grid and I have checkboxes in each cell (5 checkboxes). When checkbox change state (selected or deselected) I want to get the number of selected checkboxes and update my database table.And when I refresh the grid or close and reopen the application, I should find that the selected checkboxes are always selected (read from database the number of selected checkboxe in every cell). How can I do this?

Grid code:

    @(Html.Kendo().Grid<SereneQM.Models.TableauCtrlMesureCm>()
.Name("myGrid")

   .Columns(columns =>
   {
       columns.ForeignKey(o => o.ElementsMesureId, (System.Collections.IEnumerable)ViewData["elementsMesure"], "ElementsMesureId", "Name").Title("Mesure de").Width("130px");

       columns.Bound(e => e.C_3).ClientTemplate("<input type='checkbox' value='C_3_1' id= 'C_3_c1' class='chkbx' onclick='c_3_1ChkBoxClick();' /> <input type='checkbox' value='@item.C_3'  @(item.C_3=='True' ? 'checked= checked' name='chx_3_2' id='C_3_c2'  class='chkbx' onclick='c_3_2ChkBoxClick() ;' /> <input type='checkbox' #= C_3 ? checked='': '' # class='chkbx' id= 'C_3_c3' onclick='c_3_3ChkBoxClick() ;' /> <input type='checkbox' #= C_3 ? checked='': '' # class='chkbx' id= 'C_3_c4' onclick='c_3_4ChkBoxClick() ;' /> <input type='checkbox' #= C_3 ? checked='': '' # class='chkbx' id= 'C_3_c5' onclick='c_3_5ChkBoxClick() ;' />")
             .HtmlAttributes(new { style = "text-align: center" }).Title("-3").Width(50);


       columns.Bound(e => e.C_2_5).ClientTemplate("<input class='chkbx' type='checkbox' id= 'C_2_5_c1'/> <input class='chkbx' type='checkbox' id= 'C_2_5_c2'/>")
        .HtmlAttributes(new { style = "text-align: center" }).Title("-2.5").Width(50);

       columns.Bound(e => e.C_2).ClientTemplate("<input type='checkbox' #= C_2 ? checked='': '' # class='chkbx' onclick='c_2ChkBoxClick();'/> <input type='checkbox' #= C_2 ? checked='': '' # class='chkbx' onclick='c_2ChkBoxClick();'/> <input type='checkbox' #= C_2 ? checked='': '' # class='chkbx'onclick='c_2ChkBoxClick();' /> <input type='checkbox' #= C_2 ? checked='': '' # class='chkbx' onclick='c_2ChkBoxClick();'/> <input type='checkbox' #= C_2 ? checked='': '' # class='chkbx' onclick='c_2ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("-2").Width(50);

       columns.Bound(e => e.C_1_5).ClientTemplate("<input type='checkbox' #= C_1_5 ? checked='': '' # class='chkbx' onclick='c_1_5ChkBoxClick();'/> <input type='checkbox' #= C_1_5 ? checked='': '' # class='chkbx' onclick='c_1_5ChkBoxClick();'/> <input type='checkbox' #= C_1_5 ? checked='': '' # class='chkbx' onclick='c_1_5ChkBoxClick();'/> <input type='checkbox' #= C_1_5 ? checked='': '' # class='chkbx' onclick='c_1_5ChkBoxClick();'/> <input type='checkbox' #= C_1_5 ? checked='': '' # class='chkbx' onclick='c_1_5ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("-1.5").Width(50);

       columns.Bound(e => e.C_1).ClientTemplate("<input type='checkbox' #= C_1 ? checked='': '' # class='chkbx' onclick='c_1ChkBoxClick();'/> <input type='checkbox' #= C_1 ? checked='': '' # class='chkbx' onclick='c_1ChkBoxClick();'/> <input type='checkbox' #= C_1 ? checked='': '' # class='chkbx' onclick='c_1ChkBoxClick();'/> <input type='checkbox' #= C_1 ? checked='': '' # class='chkbx' onclick='c_1ChkBoxClick();'/> <input type='checkbox' #= C_1 ? checked='': '' # class='chkbx' onclick='c_1ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("-1").Width(50);

       columns.Bound(e => e.C_0_5).ClientTemplate("<input type='checkbox' #= C_0_5 ? checked='': '' # class='chkbx' onclick='c_0_5ChkBoxClick();'/> <input type='checkbox' #= C_0_5 ? checked='': '' # class='chkbx' onclick='c_0_5ChkBoxClick();'/> <input type='checkbox' #= C_0_5 ? checked='': '' # class='chkbx' onclick='c_0_5ChkBoxClick();'/> <input type='checkbox' #= C_0_5 ? checked='': '' # class='chkbx' onclick='c_0_5ChkBoxClick();'/> <input type='checkbox' #= C_0_5 ? checked='': '' # class='chkbx' onclick='c_0_5ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("-0.5").Width(50);

       columns.Bound(e => e.C0).ClientTemplate("<input type='checkbox' #= C0 ? checked='': '' # class='chkbx' onclick='c0ChkBoxClick();'/> <input type='checkbox' #= C0 ? checked='': '' # class='chkbx' onclick='c0ChkBoxClick();'/> <input type='checkbox' #= C0 ? checked='': '' # class='chkbx' onclick='c0ChkBoxClick();'/> <input type='checkbox' #= C0 ? checked='': '' # class='chkbx' onclick='c0ChkBoxClick();'/> <input type='checkbox' #= C0 ? checked='': '' # class='chkbx' onclick='c0ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("0").Width(50);

       columns.Bound(e => e.C0_5).ClientTemplate("<input type='checkbox' #= C0_5 ? checked='': '' # class='chkbx' onclick='c0_5ChkBoxClick();'/> <input type='checkbox' #= C0_5 ? checked='': '' # class='chkbx' onclick='c0_5ChkBoxClick();'/> <input type='checkbox' #= C0_5 ? checked='': '' # class='chkbx' onclick='c0_5ChkBoxClick();'/> <input type='checkbox' #= C0_5 ? checked='': '' # class='chkbx' onclick='c0_5ChkBoxClick();'/> <input type='checkbox' #= C0_5 ? checked='': '' # class='chkbx' onclick='c0_5ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("0.5").Width(50);

       columns.Bound(e => e.C1).ClientTemplate("<input type='checkbox' #= C1 ? checked='': '' # class='chkbx' onclick='c1ChkBoxClick();'/> <input type='checkbox' #= C1 ? checked='': '' # class='chkbx' onclick='c1ChkBoxClick();'/> <input type='checkbox' #= C1 ? checked='': '' # class='chkbx' onclick='c1ChkBoxClick();'/> <input type='checkbox' #= C1 ? checked='': '' # class='chkbx' onclick='c1ChkBoxClick();'/> <input type='checkbox' #= C1 ? checked='': '' # class='chkbx' onclick='c1ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("1").Width(50);

       columns.Bound(e => e.C1_5).ClientTemplate("<input type='checkbox' #= C1_5 ? checked='': '' # class='chkbx' onclick='c1_5ChkBoxClick();'/> <input type='checkbox' #= C1_5 ? checked='': '' # class='chkbx' onclick='c1_5ChkBoxClick();'/> <input type='checkbox' #= C1_5 ? checked='': '' # class='chkbx' onclick='c1_5ChkBoxClick();'/> <input type='checkbox' #= C1_5 ? checked='': '' # class='chkbx' onclick='c1_5ChkBoxClick();'/> <input type='checkbox' #= C1_5 ? checked='': '' # class='chkbx' onclick='c1_5ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("1.5").Width(50);

       columns.Bound(e => e.C2).ClientTemplate("<input type='checkbox' #= C2 ? checked='': '' # class='chkbx' onclick='c2ChkBoxClick();'/> <input type='checkbox' #= C2 ? checked='': '' # class='chkbx' onclick='c2ChkBoxClick();'/> <input type='checkbox' #= C2 ? checked='': '' # class='chkbx' onclick='c2ChkBoxClick();'/> <input type='checkbox' #= C2 ? checked='': '' # class='chkbx' onclick='c2ChkBoxClick();'/> <input type='checkbox' #= C2 ? checked='': '' # class='chkbx' onclick='c2ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Title("2").Width(50);

       columns.Bound(e => e.C2_5).Title("2.5").ClientTemplate("<input type='checkbox' #= C2_5 ? checked='': '' # class='chkbx' onclick='c2_5ChkBoxClick();'/> <input type='checkbox' #= C2_5 ? checked='': '' # class='chkbx' onclick='c2_5ChkBoxClick();'/> <input type='checkbox' #= C2_5 ? checked='': '' # class='chkbx' onclick='c2_5ChkBoxClick();'/> <input type='checkbox' #= C2_5 ? checked='': '' # class='chkbx' onclick='c2_5ChkBoxClick();'/> <input type='checkbox' #= C2_5 ? checked='': '' # class='chkbx' onclick='c2_5ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Width(50);

       columns.Bound(e => e.C3).Title("3").ClientTemplate("<input type='checkbox' #= C3 ? checked='': '' # class='chkbx' onclick='c3ChkBoxClick();'/> <input type='checkbox' #= C3 ? checked='': '' # class='chkbx' onclick='c3ChkBoxClick();'/> <input type='checkbox' #= C3 ? checked='': '' # class='chkbx' onclick='c3ChkBoxClick();'/> <input type='checkbox' #= C3 ? checked='': '' # class='chkbx' onclick='c3ChkBoxClick();'/> <input type='checkbox' #= C3 ? checked='': '' # class='chkbx' onclick='c3ChkBoxClick();'/>")
         .HtmlAttributes(new { style = "text-align: center" }).Width(50);

       columns.Bound(e => e.MD).Title("M.D").Width(50);
   })

    .DataSource(dataSource => dataSource
        .Ajax()
        .Group(g => g.Add(p => p.Size))
        .Batch(true)
        .ServerOperation(false)
        .AutoSync(true)

.Events(events => events.Error("error_handler").RequestEnd("onGridDataSourceRequestEnd"))
.Model(model =>
{
    model.Id(p => p.Id);
    model.Field(p => p.Id);
    model.Field(p => p.C_3).Editable(false);
    model.Field(p => p.C_2_5).Editable(false);
    model.Field(p => p.C_2).Editable(false);
    model.Field(p => p.C_1_5).Editable(false);
    model.Field(p => p.C_1).Editable(false);
    model.Field(p => p.C_0_5).Editable(false);
    model.Field(p => p.C0).Editable(false);
    model.Field(p => p.C0_5).Editable(false);
    model.Field(p => p.C1).Editable(false);
    model.Field(p => p.C1_5).Editable(false);
    model.Field(p => p.C2).Editable(false);
    model.Field(p => p.C2_5).Editable(false);
    model.Field(p => p.C3).Editable(false);
})

   .Read(read => read.Action("Tab_Read", "Home").Data("getData"))
   .Create(create => create.Action("Tab_Create", "Home").Data("getData"))
   .Update(update => update.Action("Tab_Update", "Home"))
   .Destroy(destroy => destroy.Action("Tab_Destroy", "Home"))
        )
    .Scrollable()
    .HtmlAttributes(new { style = "height: 550px" })
    .Editable(editable => editable.Mode(GridEditMode.InCell))
    .Selectable()
    .Sortable()
                )

The "getData" is javascript method that content the values to add/update the database. Take a look to this screenshot to better interstand.

Grid view screenshot

Database table screenshot




Reminder check box not selected first Time in swift

image here

I am new to swift I can used reminder check box in login page working fine,

  1. when Reminder checkBox select show the credential in log text Field it's working
  2. when Reminder checkBox unselect credential is clear from the log text Field working

but when logout after if i can click reminder checkbox to unselect the reminder checkBox it's not selecting first time when I click Double its selecting,

this is the code

override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)


      let checkviewapper = UserDefaults.standard
      let logindata = UserDefaults.standard
      let data = checkviewapper.integer(forKey:"checked")

        print("data values is ",data)
        if(data == 1)
        {

          RmdButton.setImage( UIImage(named:"check.png"), for: .normal)
          emailText.text = logindata.string(forKey: "emaild_default")
          passwordText.text = logindata.string(forKey: "password_default")

        }
        else
        {

            emailText.text = ""
            passwordText.text = ""
            RmdButton.setImage( UIImage(named:"uncheck.jpeg"), for: .normal)

        }
    }


    @IBAction func checkBox(_ sender: UIButton) {


        let defautls = UserDefaults.standard
        defautls.removeObject(forKey:"checked")

        defautls.synchronize()

       if unchecked {


             let defautls = UserDefaults.standard
             defautls.set(unchecked, forKey: "checked")
             defautls.synchronize()

            if let myLoadedString = defautls.string(forKey: "checked") {

            }

            sender.setImage( UIImage(named:"check.png"), for: .normal)
            print("checked inside")
            unchecked = false
        }
        else {
            sender.setImage( UIImage(named:"uncheck.jpeg"), for: .normal)
            print("uncheckinside")
            unchecked = true
        }

    }

where I did mistake, how to set the reminder CheckBox uncheck at First Time pls help me.....!




Checkbox from datatable not handling checked event

In my page i am populating a GridView from code behind by setting the source a custom Datatable that i compile from an XML file, in this way i write the columns header and the rows title. And this works fine, so i am adding checkboxes in the cells while adding the columns in this way:

            DataTable dt = new DataTable();
        dt.Columns.Add(" ");
        foreach (XmlNode xns in doc.DocumentElement.ChildNodes[0])
        {
            foreach (XmlNode xn in xns)
            {
                string tagName = xn.Name;

                dt.Rows.Add(tagName);
            }

        } 

        dt.Columns.Add("Mattina Turno 1", typeof(bool)); //this adds the checkbox
        dt.Columns.Add("Mattina Turno 2", typeof(bool)); 
        dt.Columns.Add("Pomeriggio", typeof(bool)); 

        GridView1.DataSource = dt;
        GridView1.DataBind();

I am enabling each checkbox in my Gridview RowDataBound in this way:

 for (int i = 0; i < e.Row.Cells.Count;i++)
        {
            if (e.Row.Cells[i].GetType() == typeof(System.Web.UI.WebControls.DataControlFieldCell))
            {

            TableCell tc = e.Row.Cells[i];
            if (tc.Controls.Count > 0)
                {
                CheckBox cb = (CheckBox)tc.Controls[0];
                    if (cb != null)
                    { 
                        cb.Enabled = true;
                        colonna = ((GridView)sender).HeaderRow.Cells[i].Text;
                        riga = e.Row.Cells[0].Text;
                        cb.CausesValidation = false;
                        cb.ID = riga + " " + colonna;
                        cb.ToolTip = riga + " " + colonna;
                        cb.AutoPostBack = true; 
                        cb.CheckedChanged += new EventHandler(Cb_CheckedChanged);
                    } 

                    }  
                }
            }
        }

But when i try to handle the check event of the checkbox nothing happens. The checkchanged should call Cb_CheckedChanged but nothing happens.

this is Cb_CheckChanged:

        private void Cb_CheckedChanged(object sender, EventArgs e)
    {
        Cliccato.Text = ((CheckBox)sender).ID.ToString();
        System.Diagnostics.Debug.Write(((CheckBox)sender).ToolTip);
    }

Please Help me, i really need your help!




Why are public variables lost after an error?

I have developed the following two subs which create and remove a collection of checkboxes next to a listobject. Each distinct ID in the listobject gets a checkbox. Like this I can approve the listobject entries.

The code is the follwing:

Public CBcollection As Collection
Public CTRLcollection As Collection

Sub create_chbx()
If Approval.CBcollection Is Nothing Then
Dim i As Integer
Dim tbl As ListObject
Dim CTRL As Excel.OLEObject
Dim CB As MSForms.CheckBox
Dim sht As Worksheet
Dim L As Double, T As Double, H As Double, W As Double
Dim rng As Range
Dim ID As Long, oldID As Long

Set CBcollection = New Collection
Set CTRLcollection = New Collection
Set sht = ActiveSheet
Set tbl = sht.ListObjects("ApprovalTBL")
Set rng = tbl.Range(2, 1).Offset(0, -1)
      W = 10
      H = 10
      L = rng.Left + rng.Width / 2 - W / 2
      T = rng.Top + rng.Height / 2 - H / 2

For i = 1 To tbl.ListRows.count
      ID = tbl.Range(i + 1, 1).Value
      If Not (ID = oldID) Then
            Set CTRL = sht.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, DisplayAsIcon:=False, Left:=L, Top:=T, Width:=W, Height:=H)
            Set CB = CTRL.Object
            CBcollection.Add Item:=CB
            CTRLcollection.Add Item:=CTRL
      End If

      Set rng = rng.Offset(1, 0)
      T = rng.Top + rng.Height / 2 - H / 2
      oldID = ID
Next i
End If
End Sub


Sub remove_chbx()
If Not Approval.CBcollection Is Nothing Then
With Approval.CBcollection ' Approval is the module name
      While .count > 0
            .Remove (.count)
      Wend
End With
With Approval.CTRLcollection
      While .count > 0
            .Item(.count).Delete
            .Remove (.count)
      Wend
End With
Set Approval.CBcollection = Nothing
Set Approval.CTRLcollection = Nothing
End If
End Sub

This all works pretty well. No double checkboxes and no errors if there are no checkboxes. I am developing an approval scheme were I need to develop and test other modules. If I now run this sub:

Sub IdoStupidStuff()
Dim i As Integer
Dim Im As Image

i = 1
Set Im = i
End Sub

It will give me an error. If I then try to run one of my checkbox subs they will not work properly anymore. The collection is deleted by the error and I am no longer able to access the collections. Why does this happen and am I able to counter act this other then just not causing errors? Is there a better way to implement such a system were loss of collections is not an issue?




Wordpress checked current user

I am new in Wordpress.I want to current user checked in checkbox by default . How to do this. echo "";




dimanche 27 août 2017

how to get the value of checkbox which is inside the combo box WPF?

i have a combobox and the checkbox is present inside the combobox.i want the value of the multi selection checkbox.

my code-

    <ComboBox Name="LocationFilterComboBox" Width="100" SelectedItem="{Binding LocationValue}"  >
   <ComboBox.ItemTemplate >
 <DataTemplate>
<StackPanel Orientation="Horizontal" >
 <CheckBox Content="{Binding LocationValue}"  IsChecked="{Binding ElementName=all, Path=IsChecked, Mode=TwoWay}" Width="120" />
 </StackPanel>
</DataTemplate>
 </ComboBox.ItemTemplate>
</ComboBox>




How to unmark header checkbox on dataGridView after refreshing the data c#?

Header check box on selection select all the check boxes in the checkbox column. After selecting the header checkbox, when data refreshes, it is still displayed as marked on it.




PHP Radio Button Secure When Emailing

I've been trying to figure out if radio buttons and checkboxes need to be stripped (cleaned?) when sending them via email.

I have a contact form that just emails the information. It doesn't touch a database. Do I need to protect the radio buttons and checkboxes when emailing? Is it possible?

I haven't found anything on google regarding securing these when emailing them. I keep coming across a few answers that say that should definitely be protected when sending to a database. The same is found here, or questions regarding how to grab values or create one dynamically. So, I'm at a loss.

Do I secure radio buttons and checkboxes when emailing? Is it possible? Necessary? Here's what my code looks like, partially:

    $firstName = strip_tags($_POST['firstName']);
    $lastName = strip_tags($_POST['lastName']);
    $email = strip_tags($_POST['emailAddress']);
    $telNum = strip_tags($_POST['phoneNumber']);
    $colors= $_POST['eColors'];
    $additionalComments = strip_tags($_POST['additionalComments']);
    $spamField = strip_tags($_POST['sField']);


    <form id="contact-form" action="" method="post">

    <div>
            <input type="text" id="nameFirst" name="firstName" /> 
            <label for="nameFirst" class="nameIcon">
                <span>First Name</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="text" id="nameLast" name="lastName" />
            <label for="nameLast" class="nameIcon">
                <span>Last Name</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="email" id="eAddy" name="emailAddress" />
            <label for="eAddy" class="emailIcon">
                <span>Contact Email</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="tel" id="telNum" name="phoneNumber" />
            <label for="telNum" class="contactIcon">
                <span>Contact Number</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <div>
            <input type="checkbox" id="cbEColors" name="eColors" class="cbSwitch" />
            <label for="cbEColors">Do you expect more color?</label>
        </div>

        <div>
            <textarea id="addComments" name="additionalComments"></textarea>
            <label for="addComments" class="messageIcon">
                <span>Additional Comments</span>
            </label>
            <span class="hint">
                <p>Input hint goes here</p>
            </span>
        </div>

        <input type="text" id="sField" class="col" name="sField" />

        <button id="submit" name="submit" type="submit" value="Submit">Submit</button>

    </form>




How to change value of textbox when a checkbox is selected C# winforms

I have 1 label and 4 checkboxes. What I want to do is when a checkbox is selected I want the price to increase or decrease in the textbox depending on if the checkbox was unchecked or not. I am lost on how I can do that.

label is TextBlock_Price

checkboxes are the following: phScreenRepair, virusRemoval, hardwareRepInstall, softwareInstall My code:

     public float? MultipleServiceAdder()
    {
        if (phScreenRepair.Checked)
        {
            return 20.00f;
        }
        if (virusRemoval.Checked)
        {
            return 10.00f;
        }
        if (hardwareRepInstall.Checked)
        {
            return 10.00f;
        }
        if (softwareInstall.Checked)
        {
            return 5.00f;
        }
        textBlock_Price.Text = "$0.00";
        return 0f;
    }




Checkbox submits only one checkbox value

I have a form with multiple checkboxes, say A, B, C, D. Sometimes i will want the user to select more than one checkboxes, say B and C. When I do that I will see only the last value 'C' in the database. How will I modify my codes below to have BC submitted to the database?

FORM

<form id="myform" method="post" action="check_trash.php">
<input type="text" name="afam" require />

A<input type="checkbox"name="get_value[]" value="A">  
B<input type="checkbox" name="get_value[]" value="B">  
C<input type="checkbox"name="get_value[]" value="C">  
D<input type="checkbox" name="get_value[]" value="D">

<button id="subm" name="upload" style="color:#fff; padding:5px 66px" class="btn btn-success" ><b>Save</b></button>
</form>

Jquery

$("#subm").click( function() {

$.post( $("#myform").attr("action"), $("#myform").serialize(), function(info){ $("#result").html(info); } );
clearInput();
});

$("#myform").submit( function() {
    return false;
});

function clearInput() {
$('#myform').each(function(){
this.reset();
});    
}

PHP

if(!empty($_POST["get_value"])){
foreach($_POST["get_value"] as $checkbox){
}
$name = $_POST['myname'];
$insert_query = "insert into trash (checkbox,name) values ('$checkbox','$name')";

$run_query = mysqli_query($con, $insert_query);
if($run_query){
    echo "Submitted successfully";
}
else {
    echo "failed";
}
}

else{
echo "<script>alert('Please select at least one option!')</script>";
}




Fetching multiple check box items and its corresponding text box value in JSP

I am a beginner and I am trying to do the following I have a JSP page which fetches records from database. the records are displayed with a checkbox and also an additional input text box field. I want user to select multiple records and then a submit button which on clicking will put the selected checkbox table records(all fields) and the textbox item to a bean object Since there will be multiple checkboxes I am not sure how to add the records




samedi 26 août 2017

Check CheckBox inside inner Repeater from outer Repeater checked in Asp.Net

There are two CheckBoxes one is in outer Repeater and other is inside inner Repeater.

I would like to automatically check CheckBox of inner Repeater when checked the outer Repeater's CheckBox.

HTML Markup:

<asp:Repeater ID="repOuter" runat="server">
    <ItemTemplate>
        <asp:CheckBox ID="chkOuter" runat="server" 
             OnCheckedChanged="chkOuter_CheckedChanged" />

        <asp:Repeater ID="repInner" runat="server">
            <ItemTemplate>
                <asp:CheckBox ID="chkInner" runat="server" />
            </ItemTemplate>
        </asp:Repeater>

    </ItemTemplate>
</asp:Repeater>

Code-Behind

protected void chkOuter_CheckedChanged(object sender, EventArgs e)
{
    // can't have access to inner CheckBox placed inside Inner Repeater
    CheckBox innerCheckBox; // how?

    innerCheckBox.Checked = true; // want to check it
}




Set User Preference from checkbox Symfony

I need help. I have 3 entities: Customer OneToMany Preference ManyToOne Typology.

Customers must be able to set their own user 'Preferences' via a 'Typologies' checkbox. Preferences can be changed when the user wants it.

The form should show preferences in the db as checked.

I'm new of Symfony and I don't know how to do this. How do I build the form? How can I handle data in db?

Here the entities:

Preference.php

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Preference
 *
 * @ORM\Table(name="preference", indexes={@ORM\Index(name="fk_preference_typology1_idx", columns={"typology_id"}), @ORM\Index(name="fk_preference_customer1_idx", columns={"customer_id"})})
 * @ORM\Entity
 */
class Preference
{
    /**

     *
     * @ORM\Column(name="id", type="integer", length=45)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="date", type="datetime", nullable=true)
     */
    private $date;

    /**
     * @var \AppBundle\Entity\Customer
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Customer")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
     * })
     */
    private $customer;

    /**
     * @var \AppBundle\Entity\Typology
     *
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Typology")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="typology_id", referencedColumnName="id")
     * })
     */
    private $typology;

    /**
     * @return Customer
     */
    public function getCustomer()
    {
        return $this->customer;
    }

    /**
     * @param Customer $customer
     */
    public function setCustomer($customer)
    {
        $this->customer = $customer;
    }

    /**
     * @return Typology
     */
    public function getTypology()
    {
        return $this->typology;
    }

    /**
     * @param Typology $typology
     */
    public function setTypology($typology)
    {
        $this->typology = $typology;
    }


}

Typology.php

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Typology
 *
 * @ORM\Table(name="typology")
 * @ORM\Entity
 */
class Typology
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="value", type="string", length=100, nullable=false)
     */
    private $value;


}

Thanks




Dynamic setting input type in Angular

Please can anybody explain why this code doesnt work, i try set input types dynamically, but this is not working.

//our root app component
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import { FormsModule }   from '@angular/forms';

@Component({
  selector: 'my-app',
  template: `
    <form #f="ngForm">

      <input [type]="rtype" value="beef" name="food" [(ngModel)]="myFood"> Beef
      <input [type]="rtype" value="lamb" name="food" [(ngModel)]="myFood"> Lamb
      <input [type]="rtype" value="fish" name="food" [(ngModel)]="myFood"> Fish
    </form>

    <p>Form value: </p>  <!-- {food: 'lamb' } -->
    <p>myFood value: </p>  <!-- 'lamb' -->
  `,
})
export class App {
  name:string;
  myFood = 'lamb';
  rtype='radio';
  constructor() {
    this.name = `Angular! v${VERSION.full}`
  }
}

@NgModule({
  imports: [ BrowserModule,FormsModule       ],
  declarations: [ App ],
  bootstrap: [ App ]
})
export class AppModule {}

also i try use type=, but this also doesnt work

I am read this http://ift.tt/2sTHNtK. But not understand why it is not working in Angular. May be angular not call http://ift.tt/2wQQdo6. Please explain.

Also when i create simple radio in html< and then try change the input type property from console it works fine for example was input.type="radio", became input.type="checkbox" in browser i see that radio changed to the normal checkbox.




PHP checkboxes database

I have been unable to get my code to after many hours of attempts. This is a very simple problem but i can't make sense of it so i have come here. So what my code does is check if the checkboxes have been checked and record it as a 1(false) or 2(true)Just look at the checkboxes My code below then should use that input to show the right tables from my database. This is the code that is broken (sorry about it being a image i could not figure out how to format code on this website

So what the problem is When only one checkbox is checked it shows the right table but if i check all 3 it shows only one (the one with printf("spell"))

Dose anyone have any idea what is going wrong.




How to make shiny group checkbox not reactive

I am building an app in shiny where user chooses conditions for analysis and also can filter data before analysis. So whenever he changes the dataset he also needs to reassign the checkboxgroup and it is a bit annoying. Is there a way to store the checkboxes values or make them not reactive?




group of checkboxes with that work correctly

I searched a lot but couldn't find a correct answer that I'm looking for. I want to have a group of checkboxes in a form that if they are checked, they work correct and show it in a div tag.

export class MyComponent {
options = [
{name:'OptionA', value:'1', checked:true},
{name:'OptionB', value:'2', checked:false},
{name:'OptionC', value:'3', checked:true}
]
get selectedOptions() { // right now: ['1','3']
return this.options
          .filter(opt => opt.checked)
          .map(opt => opt.value)
  }
}

and html:

<div class="form-group">
<label for="options">Options:</label>
<div *ngFor="let option of options">
    <label>
        <input type="checkbox"
               name="options"
               value=""
               [(ngModel)]="option.checked"/>
        
    </label>
</div>

but I'm sure it's not correct because the checked property is given by myself and if user changes it doesn't work. Could you please help me to write a simple code for checkbox? Thank you very much.




vendredi 25 août 2017

PHP keep checkbox checked after submitting POST form

How can I keep checkbox checked after submitting a form? I tried to this method:

<input type = "checkbox" name="math[]" value="Addition" <?php if(isset($_POST['math'])) echo "checked='checked'";?>/>Addition<br>

but all of my checkbox will keep checked even if I only select one, here is my code:

<form id="calc" action="calculator.php" method="POST" >
<b>Enter First No:  <br>    
<input type = "text" name="num1" value="<?php if(isset($_POST['num1'])){echo $num1;} ?>" required="required"/><br>
Enter Second No: <br>
<input type = "text" name="num2" value="<?php if(isset($_POST['num2'])){echo $num2;} ?>" required="required"/><br>
<b>Select Operation: <br>
<input type = "checkbox" name="math[]" value="Addition" <?php if(isset($_POST['math'])) echo "checked='checked'";?>/>Addition<br>
<input type = "checkbox" name="math[]" value="Subtraction" <?php if(isset($_POST['math'])) echo "checked='checked'";?>/>Subtraction<br>
<input type ="submit" value="compute" name="btnsubmit"> <br>

Thanks!




Checkbox.Ischecked always gives false

My checkbox is always returning false. Can some one please help me.This is my html div.

     <div class="large-12 columns">
                                     <label for="Data_AlternatePhones[i]_IsPrimary">
                                        <input class="toggle_enabled hidden-field" id="Data_AlternatePhones[i]_IsPrimary" name="Data.AlternatePhones[i].IsPrimary" value="true" type="checkbox">
                                        <span class="custom checkbox"></span>
                                        <input name="Data.AlternatePhones[i].IsPrimary" value="false" type="hidden">IsPrimary
                                    </label>

                                </div>

When the checkbox is checked, the page inspector code shows the following html snippet

    <div class="large-12 columns">


                                    <label for="Data_AlternatePhones[i]_IsPrimary">
                                        <input class="toggle_enabled hidden-field" id="Data_AlternatePhones[i]_IsPrimary" name="Data.AlternatePhones[i].IsPrimary" value="true" type="checkbox">
                                        <span class="custom checkbox checked"></span>
                                        <input name="Data.AlternatePhones[i].IsPrimary" value="false" type="hidden">IsPrimary
                                    </label>

                                </div>

When the checkbox is NOT checked, the page inspector code shows the following html snippet

    <div class="large-12 columns">


                                    <label for="Data_AlternatePhones[i]_IsPrimary">
                                        <input class="toggle_enabled hidden-field" id="Data_AlternatePhones[i]_IsPrimary" name="Data.AlternatePhones[i].IsPrimary" value="true" type="checkbox">
                                        <span class="custom checkbox"></span>
                                        <input name="Data.AlternatePhones[i].IsPrimary" value="false" type="hidden">IsPrimary
                                    </label>

                                </div>

My data variable in jQuery code is giving isPrimary = false in both case.

     var data =
            {
                customerGuid: $("#Data_CustomerGuid").val(),
                contactInfoType: type,
                contactInfo: $("#Data_AlternatePhones_"+i+"__PhoneNumber").val(),
                isPrimary: $("#Data_AlternatePhones_" + i + "__IsPrimary").is(':checked'),                   
                contactInfoID: $("#Data_AlternatePhones_"+i+"__ID").val()
            };

Please help me figure this out. Thank you.




How to delete multiple rows from a datagridview by selecting the checkboxes in C#?

I have datagridview and header checkbox to check all the check boxes in the rows in the checkbox column (index of the column for all the check boxes 0). I have following code in the deleted button event:

for (int i = 0; i < datagridview.Rows.Count; i++)
            {
                if (Convert.ToBoolean(datagridview.Rows[i]
                                      .Cells[0].Value) == true)
                {
                    datagridview.Rows.RemoveAt(i);
                }

}

The datagridview.rows.count keeps decreasing as the row deleted but i in the loop keeps increasing. Thus, instead of deleting all the checked rows, it deletes some of them only. It does not delete the one with rows index 0, 1, 2 and so on with the new data in the datagridview as i increasing in the code.




Checkboxes in Xamarin.Forms

I’m trying to make a page in my app where a user selects from a list of choices, then presses done to submit what he has selected. I’m using Xamarin.Forms. I directly thought of using checkboxes to achieve this; but apparently Xamarin.Forms doesn’t have checkboxes . Anyone have any suggestions to achieve this? Thanks!




What type has a spreadsheet checkbox in vba?

I have the following code which is supposed to add a checkbox for every row in a listobject next to it. I want to develop an approval tool, which loads data from a data base and loads it into the listobject. After that i can approve or disapprove the data with the checkbox and save the changes. Since the listobject will have changeing length the checkboxes will need to be added and removed by code.

so here the code:

Sub Approval()
Dim i As Integer
Dim tbl As ListObject
Dim CBcollection As Collection
Dim CB As msforms.CheckBox ' THIS IS WRONG
Dim sht As Worksheet
Dim L As Double, T As Double, H As Double, W As Double
Dim rng As Range

Set sht = Tabelle1
Set tbl = sht.ListObjects("ApprovalTBL")
Set rng = tbl.Range(2, 1).Offset(0, -1)
      W = 10
      H = 10
      L = rng.Left + rng.Width / 2 - W / 2
      T = rng.Top + rng.Height / 2 - H / 2

For i = 1 To tbl.ListRows.Count
      Set CB = sht.OLEObjects.Add(ClassType:="Forms.CheckBox.1", Link:=False, DisplayAsIcon:=False, Left:=L, Top:=T, Width:=W, Height:=H) 
'the line before will give me an error 13 type missmatch
      CBcollection.Add (CB)
      Set rng = rng.Offset(-1, 0)
      T = rng.Top + rng.Height / 2 - H / 2
Next i

End Sub

Now the question:

What type has Checkbox in a normal spreadsheet?

I always use "Option Explicit" and I will always dim my variables to the right type and I do not want to use variant types.