mercredi 30 novembre 2016

Multiple Checkboxes in a Picture

i know how to put a picture in one checkbox (via css)

but this example: checkboxes

I want to put Checkboxes into the picture at every number exactly at this position. The checkboxes can also be next to the picture but at the exact positions.

How we do this ?

Thank you for your help




Getting a Null Object Reference when trying to set imageview resource with checkbox

So I have an app with a listview. When you click a listview item it opens a new activity. I placed a checkbox in this new activity where when its checked, it should put a checkmark next to the listview item on the previous screen. I'm running into this error I'm guessing because I'm trying to set the checkbox from the second activity that has a different content view than the listview. I hope I explained that well.

Heres my RouteDetails.java with the checkbox code

public class RouteDetails extends AppCompatActivity {

ImageView routeImage;
String routeName;
CheckBox routeCheckBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_route_details);

    //back button for route details view
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);


    ///////checkbox///////////////////////////////////////////
    routeCheckBox = (CheckBox) findViewById(R.id.routeCheckBox);
    final ImageView checkImageView = (ImageView) findViewById(R.id.checkImageView);

    routeCheckBox.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view)
        {
          if (routeCheckBox.isChecked())
          {
              checkImageView.setImageResource(R.drawable.birdsboroicon);
          }
        }
    });
    /////////////////////////////////////////////


    //sets actionbar title
    routeName = getIntent().getExtras().getString("routeName");
    getSupportActionBar().setTitle(routeName);

    //TextView for route details
    final TextView routeDetailsView = (TextView) findViewById(R.id.routeDetailsView);
    routeDetailsView.setText(getIntent().getExtras().getCharSequence("route"));

    //ImageView for route details
    routeImage = (ImageView) findViewById(R.id.routeImage);
    final int mImageResource = getIntent().getIntExtra("imageResourceId", 0);
    routeImage.setImageResource(mImageResource);

and heres the custom_row.xml that contains the imageview im trying to set based on the checkbox state.

<TextView
    android:text="TextView"
    android:layout_width="wrap_content"
    android:layout_height="51dp"
    android:id="@+id/routeText"
    android:layout_weight="1"
    android:textSize="18sp"
    android:gravity="center_vertical"
    android:textColor="@android:color/black"
    android:typeface="normal"
     />

<ImageView
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:id="@+id/checkImageView" />

So I want the checkmark to be next to the listview item after the back button is pressed.

Ill include this other code if it is relavent

heres my RouteDetails.xml that contains the checkbox

<ScrollView xmlns:android="http://ift.tt/nIICcg"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:id="@+id/activity_route_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.zach.listview.RouteDetails">


<CheckBox
    android:text="Route Climbed"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/routeCheckBox"
    android:gravity="center" />

<TextView
    android:text="TextView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/routeDetailsView"
    android:textSize="18sp"
    android:textAlignment="center"
    android:textColor="@android:color/black"
    android:layout_below="@id/routeCheckBox"/>


<ImageView
    android:layout_below="@id/routeDetailsView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/routeImage"
    android:scaleType="fitCenter"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:adjustViewBounds="true" />


</RelativeLayout>
</ScrollView>

My Custom adapter.java which creates each listview row

class CustomAdapter extends ArrayAdapter<CharSequence>{

    public CustomAdapter(Context context, CharSequence[] routes) {
        super(context, R.layout.custom_row ,routes);
    }

@NonNull
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    LayoutInflater routeInflater = LayoutInflater.from(getContext());
    View customView = convertView;
    if(customView == null){customView = routeInflater.inflate(R.layout.custom_row, parent, false);}

    CharSequence singleRoute = getItem(position);
    TextView routeText = (TextView) customView.findViewById(R.id.routeText);
    routeText.setText(singleRoute);

return customView;
}

my mainavtivity.java which is where the listview is populated

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Action Bar customization
    final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayOptions(android.support.v7.app.ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(R.layout.actionbar);

    setContentView(R.layout.activity_main);

    ///// fill listview numbers I want to add
    final String[] routeListviewNumbers = getResources().getStringArray(R.array.routeNumbers);

    //fill list view with xml array of routes
    final CharSequence[] routeListViewItems = getResources().getTextArray(R.array.routeList);
    //fills route detail text view with xml array info
    final CharSequence[] routeDetail= getResources().getTextArray(R.array.routeDetail);
    //fills route detail image view with xml array of images
    final TypedArray image = getResources().obtainTypedArray(R.array.routeImages);
    //image.recycle();

    //custom adapter for list view
    ListAdapter routeAdapter = new CustomAdapter(this, routeListViewItems);
    final ListView routeListView = (ListView) findViewById(R.id.routeListView);
    routeListView.setAdapter(routeAdapter);

    routeListView.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                    CharSequence route = routeListViewItems[position];

                    int imageId = (int) image.getResourceId(position, -1);
                    if (route.equals(routeListViewItems[position]))
                    {
                        Intent intent = new Intent(view.getContext(), RouteDetails.class);
                        intent.putExtra("route", routeDetail[position]);
                        intent.putExtra("imageResourceId", imageId);
                        intent.putExtra("routeName", routeListViewItems[position]);
                        startActivity(intent);
                    }
                }
            }
    );

}
}

and my activitymain.xml which is the listview

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="0dp"

tools:context="com.example.zach.listview.MainActivity">

<ListView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/routeListView"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />
</RelativeLayout>




All checkboxes are selected (or not) by default when loading model in Angular2

I have a weird issue.

In my html pages, I have the following code:

<tr *ngFor="let role of userRoles" style="width:100%;" >
    <td style="width:37px;">
        <input class="uicheckbox" type="checkbox" [(ngModel)]="role.IsActive" name="isActive" (click)="onCheck(role)" />
    </td>
    <td></td>
</tr>

I'm bringing in a model that has an Array of roles, some of which have set IsActive to true, some to false. The checkbox should be checked based on the role.IsActive property. But for some reason, all checkboxes are (un)checked when the model loads. Why is this happening?




how can select multiple rows from gridview and store in array in asp.net c#

I wrote code for asp.net c#

I use grid view to display information from database and I am using checkbox to select the data , but the problem How can save these data I selected in array , then save it to data base .

this my code

the grid view

            <Columns>

                <asp:TemplateField HeaderText="Select">

                    <ItemTemplate>

                        <asp:CheckBox ID="chkSelect" runat="server" onclick="Check_Click(this)" />
                    </ItemTemplate>
                </asp:TemplateField>

                <asp:BoundField HeaderText="Q_ID" DataField="Q_Multiple_ID" />

                <asp:BoundField HeaderText="The Question" DataField="Multiple_Question" />




            </Columns>

        </asp:GridView>

the c#

protected void GetSelectedRecords(object sender, EventArgs e) {

    string selected = "";
    foreach (GridViewRow row in GridView3.Rows)

        {

            CheckBox chk = (CheckBox)row.FindControl("chkSelect");


        // get the selected AutoId and cells text
        if (chk.Checked)
            {

            string QID = GridView3.DataKeys[row.DataItemIndex].Values["Q_Multiple_ID"].ToString();
            selected += QID;
            test.Text = selected;


        }
    }

    test.Text = selected;

}




c# datagrid checkbox multi delete

I have problem when I delete multichecked rows with this button. It only delete first row. cell_dellklient is the name of checkbox in dataGridView1 yes is the true value of checkbox

Please help

private void button2_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.Rows) { con.Open();

                object cell = row.Cells["cell_delklient"].Value;
                if (cell == "yes")
                {
                    SqlCommand cmd = new SqlCommand("Delete From Klienci where Nazwa ='" + row.Cells[0].Value.ToString() + "'", con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    wyczytywaniegridu();
                }
                con.Close();
            }




How to clear all checkboxes and reset the value of the checkbox in javascript

I am trying to clear all checkboxes in a map I've built. The checkboxes turn on some features of the map. Also, I can check a few and only see a few of the items and not all. For example, I have a button to show all wells and then a sub menu to allow for users to select individual owners of the wells. Once the user has checked the individual owners within the sub menu they can filter to see only those. When the user clicks the 'clear all' button it clears all the checkboxes as it should, but within the wells sub menu it acts like those individual boxes that were checked stay checked and keep that state. When I click the show all wells button again it then only shows me the sub menu wells that were checked.

// here give the sub menu checkboxes a state when clicked.

    $(".wellProducer").on("click",function(){
      $(this).val(this.checked ? 1 : 0);
    });

// once checked make only that owner visible

    $(".wellProducer").click(function(){
       if(this.checked == true){
          map.filters.selectedProducers.push(this.value);
       }
       if(this.checked == false){
           var index = map.filters.selectedProducers.indexOf(this.value);
           if (index > -1){
               map.filters.selectedProducers.splice(index, 1);
           }
        }
   });

// here is the clear all button click

    $("#resetBtn").click(function(){
       $(clearFunction).click();
    });

// here is the clear function

   function clearFunction(index){

      if(map.filters.showWells == 1){
          map.filters.showWells = 0;
      }
      $("input:checkbox").prop("checked", false);

     ReDraw();

     }




JS Checkbox works just for one time in TinyMCE

I got a problem with a checkbox, i added a checkbox into TinyMCE adimage in magento. It just put some code around the inserted image, that the lightbox addon will work and you don't have to add the code manually. It is in the backend of magento.

i added this to image.htm:

                        <td class="column1"><label id="lightboxlabel" for="lightbox">{#advimage_dlg.lightbox}</label></td>
                        <td><table role="presentation" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                                <td><input type="checkbox" id="lightbox" name="lightbox" class="checkbox" checked="checked" /></td>
                                <!-- <td><label id="lightboxlabel" for="lightbox">{#advimage_dlg.lightbox}</label></td> -->
                            </tr>
                        </table></td>

and this to image.js in insertAndClose():

            if (f.lightbox.checked) {

           ed.execCommand('mceInsertContent', false, '<a href="' + args.src + '"}} data-lightbox="' + args.alt + '" data-title="' + args.title + '">' );
        }

now, when i make a new cms page and wanna add an image with wysiwyg editor i can add the first image with the code and every image after that won't get the code. if a delete "if (f.lightbox.checked)" it will put the code around it every time, so probably there is a problem with the get of the checkbox boolean.




CheckBox Not Binding in PartialView AJAX PostBack

I have a form with a field and a checkbox in an Ajax Form on a Modal Popup, When the user enters the data in the textbox and presses submit the values are posted and the Modal is closed. However if the user enters a value in the textbox and then checks the the checkbox the form will submit and the view will return to the modal on this time if the checkbox is checked I need to leave the form so that the user can submit another entry. The issue is that the textbox maintains its state, which is what I want and so does the Checkbox, but, the Underlying value of the checkbox switches back to false even though the checkbox is still checked...
A little stumped.

@using (Ajax.BeginForm("SaveValues", "ControllerName", new AjaxOptions()
{   HttpMethod = "Post",
OnComplete = "ChkForCheckBox();"
}))
{ 
@Html.TextBoxFor(x => x.DDate)
@Html.CheckBoxFor(x => x.Dupe)
<button type="submit" >Save</button>
}

and in the Controller.

public void SaveValues( string DDate, bool Dupe)
{
   var rslt = repo.Post(DDate);
}

The JS.

 function ChkForCheckBox(){
    var rslt = $('#Dupe').prop('checked');
    if(!rslt){
     //Close Modal
}
}

However after the Ajax Post the CheckBox is still checked but the JS Script Check shows false? If I comment out the CloseModal and look through the code the Value is set to False? but if I post again it comes through as true? Verifying the ChkForCheckBox() again and it shows false.....
I'm missing something.




Checkbox not functioning well on iPhone4 portrait (Responsive)

Using iPhone 4 and 5 only on portrait, when I click the checkbox, the tick shows for half a second and disappears in the middle of the line (not even on the box). The model changes, but the checkbox stays as it was when we entered portrait (if you change to landscape it will show the right state and when going back to portrait it stops working again).

It works fine on landscape or larger screens.

HTML:

<div class="col-md-12 col-xs-12">
<input type="checkbox" name="testcheckbox" id="testcheckbox" ng-model="myData" />
<label id="spantextcheckbox" for="testcheckbox">Test</label>
</div>

I got a media-query for those devices (separate for landscape and portrait), but the checkbox has no classes, means the query shouldn't work on it. Still, for some reason, the checkbox works fine on larger devices or even landscape of those devices.




How to prevent the last checkbox from unchecking in angular 2

I have a problem with angular 2, I don't know how to check back the last checkbox after unchecking. Here is my piece of HTML:

    <td *ngFor="let box of checkedBoxes"><input
            type="checkbox"
            value=""
            id=""
            [(ngModel)]="box.checked"
            (ngModelChange)="updateGroupByCheckboxes($event, box.name)">
      <label></label>
    </td>

And here my .ts code:

checkedBoxes: any[] = [{
    "name": "box1",
    "label": "Box1",
    "checked": true
  },
  {
    "name": "box2",
    "label": "Box2",
    "checked": false
  },
  {
    "name": "box3",
    "label": "Box3",
    "checked": false
  },
  {
    "name": "box4",
    "label": "Box4",
    "checked": false
  }];

And:

updateGroupByCheckboxes(event, name) {

    var counter = 0;
    for(var i = 0; i < this.checkedBoxes.length && counter <= 1; i++) {
      if(counter > 1) {
        break;
      }

      if(this.checkedBoxes[i].checked) {
        counter++;
      }
    }

    if(counter < 1 && event == false) {
      for(var i = 0; i < this.checkedBoxes.length; i++) {
        if(this.checkedBoxes[i].name == name) {
          console.log("val: " + this.checkedBoxes[i].checked);
          this.checkedBoxes[i].checked = true;
          break;
        }
      }
    }
    else {
      this.checkedBoxes[3].checked = !this.checkedBoxes[3].checked;
      var grouppingData = [];
      for(var i = 0; i < this.checkedBoxes.length; i++) {
        if(this.checkedBoxes[i].checked == true){
          grouppingData.push(this.checkedBoxes[i].name);
        }
      }
      this.statistics = this.statisticsService.getStatistics(grouppingData);
    }
  }

I have no idea why this line: this.checkedBoxes[i].checked = true; doesn't work in my case.

Any help would be appreciated.




Silverstripe 3 - Filter dataobjeccts with checkboxes

I am trying to filter dataobject results based on checkbox selection.

If a user checks 'pool' and 'garage' I would like all items to display with a pool and a garage. At the moment only one or the other works but not together.

Something similar to: http://ift.tt/2gUymFr but without the Ajax.

Is this the correct way to go about this?

public function index(SS_HTTPRequest $request) {
$properties = Property::get();

   if($pool= $request->getVar('pool')) {
        $properties= $properties
        ->filter(array(
            'Title' => 'pool'              
        ));
    }

if($garage= $request->getVar('garage')) {
        $properties= $properties
        ->filter(array(
            'Title' => 'garage'              
        ));
    }

return array (
    'Results' => $properties
);
}




mardi 29 novembre 2016

element selectors after a checked checkbox not working properly

I am toggling two images when the checkbox is clicked. The first three selectors are working fine but the last one is not working as expected, i.e., the background of 'Sample' is not rendering blue.

  <label>
   <input type="checkbox" class="input">
   <img src="sample-1.png" class="img-1" >
   <img src="sample-2.png" class="img-2" >
   <span>Sample</span>
 </label>

In css,

.input {
    display: none;
}
.input ~ .img-2, 
.input:checked ~ img-1 {
    display: none; 
}
.input:checked ~ .img-2 {
    display: inline-block; 
 }
.input:checked ~ span {
    background: blue;
 }

What's missing here? Thanks in advance.




AngularJs: Unable to uncheck checkbox when uncheck another checkbox

Got a problem, here the situation:
I want to uncheck the first checkbox when I uncheck the second checkbox.

Let say, by default both checkbox are checked. When I click second checkbox, I want the first checkbox to uncheck also.

HTML:

<ion-checkbox ng-model="firstCheckbox">First Checkbox</ion-checkbox>
<ion-checkbox ng-model="secondCheckbox" ng-change="uncheckFirstCheckbox(secondCheckbox)">Second Checkbox</ion-checkbox>


JS:

    $scope.uncheckFirstCheckbox = function(secondCheckbox) {
        if(secondCheckbox.checked === false) {
            $scope.firstCheckbox = false;
        };
    };


The $scope.firstCheckbox turn false but it remain uncheck in HTML.
May I know where could be the problem?




Laravel google maps hiding circle on checkbox

i'm trying to hide and show circle depends on color/index by pressing checkbox. I did form but i dont know what next. Any suggestions ?

Circle configuration :

var mark = new google.maps.Circle({
  map: map,
  center : markerLatlng,
  radius : radius,
  strokeColor:  color,
  strokeWeight: 1,
  strokeOpacity:  1,
  fillColor:    color,
  fillOpacity:  1,
  zIndex: index,
  clickable:true,
});

Form:

  {!! Form::open(['route' => 'map.index' , 'method' =>'GET' ])!!}
    <div class="form-inline">
      {!!Form::label('Very good: ','', ['class' => 'navbar-form'])!!}
      {!!Form::checkbox('very_good','value',false,['class' => 'form-control'])!!}
      {!!Form::label('Good: ','', ['class' => 'navbar-form'])!!}
      {!!Form::checkbox('good', 'value',false,['class' => 'form-control'])!!}
      {!!Form::label('Moderate: ','', ['class' => 'navbar-form'])!!}
      {!!Form::checkbox('moderate', 'value',false,['class' => 'form-control'])!!}
      {!!Form::label('Sufficient: ','', ['class' => 'navbar-form'])!!}
      {!!Form::checkbox('sufficient', 'value',false,['class' => 'form-control'])!!}
      {!!Form::label('Bad: ','', ['class' => 'navbar-form'])!!}
      {!!Form::checkbox('bad', 'value',false,['class' => 'form-control'])!!}
      {!!Form::label('Very bad: ','', ['class' => 'navbar-form'])!!}
      {!!Form::checkbox('very_bad', 'value',false,['class' => 'form-control'])!!}
    </div>
  </div>
  {!!Form::close()!!}




Binding issues with checkbox. CheckedValue property is different from Checked property. (WinForms)

Working on an apparently old bug in the company's flagship software. Looks like the issue (not prompting for save appropriately) is boiling down to the fact that a checkbox is checked on the UI (and the checkbox.Checked property is True), but the checkbox.CheckedValue property is false. The data binding is done to CheckedValue (just like other checkboxes in the system).

What gives? I searched, but I can't find any reason why the checkbox.Checked property should have a different value from the checkbox.CheckedValue property. How could they??

Can anyone help elucidate the difference here?




HOw to make mysql query based on multiple checkboxes

I am trying to make a query based on multiple checkboxes.(For exapmle for e-shop )

Checkboxes

         <div id="car">       
            <label><input type="checkbox" value="red" >red</label>
            <label><input type="checkbox" value="black" >black</label>
            <label><input type="checkbox" value="blue" >blue</label>          
          </div>


        <div id="brand">
            <label><input type="checkbox" value="mazda" >mazda</label>
            <label><input type="checkbox" value="bmw" >bmw</label>

        </div>

Query

 $brand = $_POST['brand'];
 $color = $_POST['color'];

$Query = "SELECT * FROM items WHERE brand IN ('".implode(",", $brand)."') ";

$QueryResult = mysqli_query($connection , $Query);


while($QueryRow = mysqli_fetch_assoc($QueryResult)){
?>
<div><p><?php echo $QueryRow['cost'];?></p></div>
<div><img src="<?php echo $QueryRow['img']; ?>"></div>
<?php
}
}
    ?>

Also , I have js script for passing array with values taken from checkboxes, but it doesn't related to problem, that is why I do not post script.

Problem:

1- How can I add AND in query for taking into account color to?

2- How to avoid error if COLOR-check box have not been checked?

Any ideas?




Get checkbox value from HTML in Angular 2 typescript.

I have two checkboxes in my html as follows:

<label><input type="checkbox" id="checkbox1" /> Folder 1: </label>
<label><input type="checkbox" id="checkbox2" /> Folder 2: </label>

but I'm unsure of how to retrieve the checkbox values inside my Typescript file. I know I can accomplish this by calling a separate function for each checkbox and changing a value within my typescript. However, that doesn't seem like the best way - if I had ten different checkboxes then I would need 10 different functions in my typescript.

Is there a simply way to get whether the checkbox is on or off based on the id? Is there a better way than that?




Need help connecting

I'm using Expression Web 4, all my files are in a folder on the Desktop, but the page says the file can't be found. I am trying to host from my computer since I will only have this up for 1 day.

It would show up in the search bar like this:
file:///C:/UsersnameDesktopName_websiteWebsitePage.html

But I have the file path like this:
C:\Users\name\Desktop\Name_website\WebsitePage.html

The html code:(these are only a few of many)
All of the check boxes are in a tag,
Each checkbox resides in it's own tag,

<form action="">
<div class="course" id="crse">
<input type="checkbox" name="course" value="53" id="crse53" class="auto-style2" /><span class="auto-style2">BMT-1650 Customer Service - 3 credits</span><br class="auto-style2"/>
<input type="checkbox" name="course" value="54" id="crse54" class="auto-style2" /><span class="auto-style2">Cyber Law - 3 credits</span><br class="auto-style2"/>
<input type="checkbox" name="course" value="55" id="crse55" class="auto-style2" /><span class="auto-style2">BMT-2880 Emergency Management - 3 credits</span><br class="auto-style2"/>
</div>
</form>

<input id="clickme"type="button" value="Find my Certificate" onclick="doFunction();"/>

The javascript code: I'm trying to connect the if statement to the button which will lead the user to certain html page that is stored on my computer. The file is the same folder as the other html files.

var crse53 = document.getElementById('crse53').checked,   
crse54 = document.getElementById('crse54').checked,   
crse55 = document.getElementById('crse55').checked,    
crse56 = document.getElementById('crse56').checked,   
crse57 = document.getElementById('crse57').checked,   
crse58 = document.getElementById('crse58').checked;


if (crse53 == false && crse54 == false && crse57 == false && crse58 == false){

var myBtn = document.getElementById('clickme');

myBtn.addEventListener('click', function(event) {
    window.location.href='C:\Users\name\Desktop\Name_website\WebsitePage.html';});

document.getElementById("clickme").onclick = doFunction;

} else {
alert("try again");
};

I don't know whats wrong. Is it the file path or the something else?




Update Sql with gridview checkbox

I have a gridview set in ASP.Net that has a name and a checkbox.

          <h4>Current Instructor</h4>
            <div class="hide-overflow">
                <asp:GridView runat="server" ID="GridViewInstructor" DataSourceID="SqlDataSourceInstructor" AutoGenerateColumns="false" CssClass="table table-bordered table-striped" ShowHeader="false" EmptyDataText="No Instructor associated to class." DataKeyNames="Instructor">
                    <Columns>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:CheckBox ID="CBInstructorPrimary" runat="server" Checked='<%#Eval("Primary")%>' OnCheckedChanged="PrimaryUpdate" AutoPostBack="true" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField DataField="InstructorName" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource runat="server" ID="SqlDataSourceInstructor" DataSourceMode="DataReader"  ConnectionString="<%$ ConnectionStrings:HRAgriConnectionString %>"
                    SelectCommand="
                        SELECT a.Primary, a.ClassID, a.Instructor, b.LName + ', ' + b.FName as InstructorName
                        FROM tblClass a
                        LEFT JOIN tblUser b
                        ON a.Instructor = b.UserName
                        WHERE a.ClassID = @classID
                        ORDER BY a.Primary DESC">
                    <SelectParameters>
                        <asp:QueryStringParameter Name="classID" QueryStringField="cid" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </div>  

This makes a gridview table that looks like

enter image description here

my c# code behind looks like this

protected void PrimaryUpdate(object sender, EventArgs e)
{

    //CheckBox activeCheckBox = sender as CheckBox;

    //foreach (GridViewRow rw in GridViewInstructor.Rows)
    //{
    //    CheckBox chkBx = (CheckBox)rw.FindControl("CBInstructorPrimary");
    //    if (chkBx != activeCheckBox)
    //    {
    //        chkBx.Checked = false;
    //    }
    //    else
    //    {
    //        chkBx.Checked = true;
    //    }
    //}

    string constr = ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.CommandText = "UPDATE tblClass SET [Primary] = @Primary WHERE classID=@classID and Instructor = @InstructorName";
            cmd.Connection = con;
            con.Open();
            foreach (GridViewRow row in GridViewInstructor.Rows)
            {
                //Get Instructor Name.
                string InstructorName = row.Cells[0].Text;

                //Get the Class Id from the DataKey property.
                classID = Request.QueryString["cid"];

                //Get the checked value of the CheckBox.
                bool Primary = (row.FindControl("CBInstructorPrimary") as CheckBox).Checked;

                //Save to database
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@Name", SalesmanName);
                cmd.Parameters.AddWithValue("@classID", classID);
                cmd.Parameters.AddWithValue("@Primary", Primary);
                cmd.ExecuteNonQuery();
            }
            con.Close();
            Response.Redirect(Request.Url.AbsoluteUri);
        }
    }
}

The outcome should be if you check another checkbox it will update the Primary field (which is a bit field) to 1 if checked and all others in that group will be set to 0. And only 1 checkbox can be checked at a time. I know I have commented out the top part for now. I just haven't been able to figure out how to get this working.




Populating checkbox from server side data using 2 loops


I have a need to check the checkboxes which values are available in the database, with that i has to display additional options avaialable also.
I was trying, as i am using two loops it's repeating the same set of checkboxes and check differnt values in each instance.
I need to check the appropriate checkboxes in first loop itself. Is there any way to achieve this
The following was my output enter image description here
Following is the code i am using

$sid;//Retrived from DB
$iDLst=array();
$sql1 = "SELECT
`id1`
FROM `tbl1` 
where `tbl1_sid`='" . $sid . "'";
$result1 = $conn->query($sql1);
if ($result1->num_rows > 0) {
    while ($row = $result1->fetch_assoc()) {
        $iDLst[]=$row['id1'];
    }
}
foreach ($iDLst as $id){
    $sql2 = "SELECT
    `id`,
    `nme`
    FROM `tbl2`;
    ";
$result2 = $conn->query($sql2);
    if ($result2->num_rows > 0) {
        while ($rowC = $result2->fetch_assoc()) {

            if (strpos($rowC['id'], $id) !== FALSE ) {
                echo ' <input value="' . $rowC['id'] . '" type="checkbox" name="upD[]" checked/>  <label>' . $rowC['nme'] . ' &nbsp;&nbsp;&nbsp;</label>';


            }  else {
                echo ' <input value="' . $rowC['id'] . '" type="checkbox" name="upD[]" />  <label>' . $rowC['nme'] . ' &nbsp;&nbsp;&nbsp;</label>';
            }


        }
    }
}

Note: I have changed to general code, There is no errors in code. I am getting the display. I need the solution regarding the logic part...




Reposition the Outline in CCustomButton in C++(CheckBox)

I am using the CCustomButton Checkbox to add a checkbox in my window. Now as the checkbox is selected certain outline is created around the checkbox which is out of shape as in the picture I have attached.

I want to align that outline according to the checkbox that is checkbox in the middle . I am not sure what function of CCustomButton I can use to do this.

Now that I have to reposition the outline for the checkbox. Here is my code:

checkbox.MoveWindow(left, top, cx*COL_APPY_W_PCNT, 20);

where COL_APPY_W_PCNT is Percentage Width of the Checkbox which is 4/100.

I am getting this now:

enter image description here

I think all of the parts except the left part of this outline is not in its position. Is there any way I can align them?




HTML checking for mutiple checkbox

I'm writing a piece of code as an exercice in HTML that allows the user to tick boxes (the code below is simplified, from 8 checkboxes to 2) and the text totalPrice should show the price of the item selected.

<script type='text/javascript'>
function f(){
  if(document.form1.nano1Gb.checked == true)
    document.form1.totalPrice.value = document.form1.priceNano1Gb.value 
  if(document.form1.nano4Gb.checked == true)
    document.form1.totalPrice.value = document.form1.priceNano4Gb.value 
  if(document.form1.nano1Gb.checked == true && document.form1.nano4Gb.checked == true)
    document.form1.totalPrice.value = parseInt(document.form1.priceNano1Gb.value) + parseInt(document.form1.priceNano4Gb.value)
}
</script>
<body>
<form name='form1'>
<p>
<input type='checkbox' name='nano1Gb' onclick=f(); />
<input type='text' value='Nano 1GB'>
<input type='text' name='priceNano1Gb' value='90'</p>

<p>
<input type='checkbox' name='nano4Gb' onclick=f(); />
<input type='text' value='Nano 4 GBb'>
<input type='text' name='priceNano4Gb' value='155'</p>

<p><input type='text' name="totalPrice" placeholder="Total Price"></p>

This works with two elements, but with 8 elements, it seems highly inefficient for me to great hundreds of conditions checking every single box and totaling what else has been checked. How can I code this better? Thanks!




lundi 28 novembre 2016

Dynamic Arraylist of checkboxes in Java Swing

I'm writing a GUI Java program for student registration which will retrieve available classes from database, give the user an option to choose classes and then store this in DB.

What I'm trying to do and have so far achieved partial success, is this - I created a combobox with the available majors (got that from DB), retrieved the available classes for that major and displayed checkboxes for these classes.

There are two issues with this code. 1. After selecting the major from combobox, the checkboxes aren't displayed. They appear one by one only when I hover my cursor. 2.Once I change my major in the combobox, the checkboxes are not updated, even though the console in eclipse says checkboxes for newly selected major has been created.

ArrayList<JCheckBox> checkBoxes=new ArrayList<JCheckBox>();
    //combox action listener below
    public void actionPerformed(ActionEvent e) 
    {

      //get all available classess for the selected major
        avail_class = new String[count_class];


        //get all available class ids
        avail_classid = new String[count_class];

        JCheckBox checkbox;
        int xdim = 75;
        for (int i = 0; i < count_class; i++) 
            {
                checkbox = new JCheckBox(avail_classid[i] + "-" + avail_class[i]);
                checkbox.setBackground(new Color(0, 255, 255));
                checkbox.setBounds(183, xdim, 289, 23);
                contentPane.add(checkbox);
                checkBoxes.add(checkbox);
                checkbox.setEnabled(true);

                xdim = xdim + 50;

            }


    }




how to get the previous checked position in list view

Actually I had a list view when i touch on the list view i will get popup window with check boxes when i check the check box and press ok then the dialog box closes and when i touch again the list view then the checked row position will change the background color and and stored into the data base . actually what was the issue is when i again select different item position and checked and press ok and again touch the list view instead of entering the checked position entering into data base the previously checked position also entering into data base along with current checked position . so i need to get previous position and clear position before the list view sees the checked positions . so that it only enters current position.please help me.

My activity:

listView1.setOnTouchListener(new AdapterView.OnTouchListener() {

              @Override
              public boolean onTouch(View v, MotionEvent event) {
                     if(event.getAction() == MotionEvent.ACTION_UP){



                   newListitems2.clear();
                newListitems2.addAll(itemsList1);


                   dialog = new Dialog(PendingOrdersActitvity.this);
                      dialog.setContentView(R.layout.itembumping);

                      dialog.show();

                      //listView1.setTag(position);
                      list1=(ListView )dialog.findViewById(R.id.list1);

                      ItemBumpingAdapter adapter2 = new ItemBumpingAdapter(PendingOrdersActitvity.this,newListitems2);
                      list1.setAdapter(adapter2);




                  Button okButton = (Button)dialog.findViewById(R.id.ok1);
                      okButton.setOnClickListener(new OnClickListener() {

                          @Override
                          public void onClick(View v) {

                              dialog.dismiss();

                          }
               });
                          Button cancelButton = (Button)dialog.findViewById(R.id.Cancel1);
                  cancelButton.setOnClickListener(new OnClickListener() {

                      @Override
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
                          dialog.dismiss();
                      }



                      });
                      return true;

Adapter:

              final ViewHolder holder;
              String item = null, qty = null;
              if (convertView == null) {
                  holder = new ViewHolder();
                  convertView = inflator.inflate(R.layout.itembumpingadapter, null);
                  holder.qty = (TextView) convertView.findViewById(R.id.qty);
                  holder.name = (TextView) convertView.findViewById(R.id.item);
                  holder.childText = (TextView) convertView
                          .findViewById(R.id.childitem);
                  holder.qtyChild = (TextView) convertView
                          .findViewById(R.id.qtychild);
                   holder.checkbox = (CheckBox) convertView.findViewById(R.id.chckbox1);
                  convertView.setTag(holder);




              } else {

                  holder = (ViewHolder) convertView.getTag();
              }
              parentobjid=newListitems.get(position).getParentobjectid();
              if(!parentobjid.isEmpty())
              {
                  holder.name.setText("   " +newListitems.get(position).getItemnNameDisplay());
                  holder.name.setTextColor(Color.parseColor("#CC0000"));
                  holder.qty.setText("      "+String.valueOf(newListitems.get(position)
                          .getQuantityDisplay()));
                  holder.qty.setTextColor(Color.parseColor("#CC0000"));
              }
              else
              {

              holder.name.setText(newListitems.get(position).getItemnNameDisplay());
              holder.qty.setText(String.valueOf(newListitems.get(position)
                      .getQuantityDisplay()));
              holder.name.setTextColor(Color.parseColor("#FFFFFF"));
              holder.qty.setTextColor(Color.parseColor("#FFFFFF"));

// for(int i1=0;i1

// if(newListitems.get(i1).getCount()==1){
//newListitems.remove(i1); // } // }

holder.checkbox.setChecked(newListitems.get(position).isChecked() );

              holder.checkbox.setChecked(false);
              holder.checkbox.setTag(position);

              holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                  @Override
                  public void onCheckedChanged(CompoundButton buttonView,
                          boolean isChecked) {


                      int position=(Integer)buttonView.getTag();


                        newListitems.get(position).setChecked(!newListitems.get(position).isChecked());


                  }
              });



                if(newListitems.get(position).isChecked()){
                       for (int i = 0; i <newListitems.size(); i++) {
                           if(i == position){ 
                           convertView .setEnabled(false);
                              convertView .setClickable(false);
                               convertView .setBackgroundColor(Color.parseColor("#DCDBDB"));


                  //holder.name.setEnabled(true);
                  //holder.name.setBackgroundColor(Color.parseColor("#DCDBDB"));

                    ItemsBean bean=new ItemsBean();
                    bean.setInvNo(newListitems.get(position).getInvNo());
                    bean.setItemnNameDisplay(newListitems.get(position).getItemnNameDisplay());
                    bean.setLinenum(newListitems.get(position).getLinenum());
                    bean.setQuantityDisplay(newListitems.get(position).getQuantityDisplay());
                    bean.setProdnum(newListitems.get(position).getProdnum());
                      bean.setFlag(1);
                      bean.setCount(1);

                      newListitems1.add(bean);

                    PendingOrdersActitvity.getInstance().insertintodatabase(newListitems1);

                    newListitems1.clear();



                   }
              }

The for loop condition which i kept in comment lines i tried but it didnt worked so please help me.




Unexpected behaviour from checkbox template in grid after grid is destroyed and repopulated

I am still running into an issue with my grid's checkbox template, I thought I had it fixed before but I was wrong. So whats happening is when I check a checkbox and click the edit button, my window pops up as expected and when I close the window, I destroy the grid, repopulate the grid and then the window closes. No problem..

So then I check another checkbox, so I can edit another record and no matter what checkbox i check, the checkbox in the first row always gets checked again and I can't figure out why this is happening, it doesnt make any sense to me

The code in question is this...

var vendorGrid,
    CreateVendorGrid = function (newData) {
    $("#Vendor-Grid").kendoGrid({
        dataSource: {
            data: newData
        },
        schema: {
            model: {
                fields: {
                    VendorID: { type: "number" }
                },
            }
        },
        filterable: {
            mode: "row"
        },
        columns: [
            {
                template: "<input name='Selected' class='checkbox' type='checkbox'>",
                width: "30px"
            },
            {
                field: "VendorName",
                title: "Vendor",
                filterable: {
                    cell: {
                        showOperators: false,
                        operator: "contains"
                    }
                }
            },
            {
                field: "Email",
                title: "Email",
                filterable: {
                    cell: {
                        showOperators: false,
                        operator: "contains"
                    }
                }
            },
            {
                field: "Phone",
                title: "Phone",
                filterable: false
            },
            {
                field: "City",
                title: "City",
                filterable: false
            }],
        scrollable: true,
        sortable: true,
        pageable: {
            pageSize: 20
        },
        selectable: "row",
        height: $("#Vendor-Grid").closest(".col-height-full").height()-60,
        change: function (e) {
        }
    }).data("kendoGrid");
}

//This to get the data to populate the grid

function GetVendorGridData() {
    kendo.ui.progress($("#Vendor-Grid"), true);
    $.ajax({
        type: "GET",
        url: URLParam.GetVendorsForGrid,
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        success: function (data, textStatus, jqXHR) {
            CreateVendorGrid(data);
            kendo.ui.progress($("#Vendor-Grid"), false);
        }
    });
}

//This is part of my script in my popup window for closing the window 

$("#btnCloseVendorEditor").click(function () {
    RefreshVendorGrid();
    GetVendorGridData();
    CloseTheWindow();
});

function RefreshVendorGrid() {
    var theGrid = $('#Vendor-Grid').data('kendoGrid');
    theGrid.destroy();
}

This has been driving me nuts from yesterday, I'm lost.




Limit checkboxes but only those newly checked

I have a bit of jquery that lets me limit the number of checkboxes a user can check on a page:

 if ($('input[type=checkbox]:checked')

But, the user is limited to 'x' number once per day. So they come to the form, submit their limit (3 checked). They come back next day, I have the 3 checked that were from yesterday but set to disabled:

 checked="checked" disabled="disabled" disabled/>

Is there a way to modify my if statement to say "input[type=checkbox]:checked" but not if disabled or not if class="disabled" so these don't count against the daily limit?




Show Or Hide Widget In ListView When Checkbox Is Checked Or Unchecked Android

Here is my ArrayAdapter Class,

public class HAAR extends ArrayAdapter<HAM> {

Context context;
ArrayList<HAM> selectedhospital;
ViewHolder viewHolder = null;

public HAAR(Context context, int resourceId,
                                        ArrayList<HAM> selectedhospital) {
    super(context, resourceId, selectedhospital);
    this.context = context;
    this.selectedhospital = new ArrayList<HAM>();
    this.selectedhospital.addAll(selectedhospital);
}

// View lookup cache
private static class ViewHolder {
    TextView name;
    TextView home;
    CheckBox chk_hospitallist;
    RadioButton rbt_primarylocation;

}


@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    final ArrayList<String> hospitalid = new ArrayList<>();

    LayoutInflater mInflater = (LayoutInflater) context
            .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);

    if (convertView == null) {
        // If there's no view to re-use, inflate a brand new view for row
        convertView = mInflater.inflate(R.layout.ha_list_item_name, null);
        viewHolder = new ViewHolder();

    viewHolder.name = (TextView) convertView.findViewById(R.id.txt_ha_name);
        viewHolder.home = (TextView) convertView.findViewById(R.id.txt_ha_town);
        viewHolder.chk_hospitallist = (CheckBox) convertView.findViewById(R.id.chk_box_ha_list);

        final View finalConvertView = convertView;
        viewHolder.chk_hospitallist.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                CheckBox cb = (CheckBox) v;
                viewHolder.rbt_primarylocation = (RadioButton) finalConvertView.findViewById(R.id.rbtn_pl);
                HAM _state = (HAM) cb.getTag();

                if(cb.isChecked())
                {
                    _state.setSelected(cb.isChecked());
                    hospitalid.add( _state.getId().toString());
                    viewHolder.rbt_primarylocation.setVisibility(View.VISIBLE);

                    Toast.makeText(
                            v.getContext(),
                            "Clicked on If: " + _state.getId().toString() + " is "
                                    + cb.isChecked(), Toast.LENGTH_LONG).show();
                }
                else
                {
                    _state.setSelected(false);
                    hospitalid.remove( _state.getId().toString());
                    viewHolder.rbt_primarylocation.setVisibility(View.INVISIBLE);

                    Toast.makeText(
                            v.getContext(),
                            "Clicked on Else: " + _state.getId().toString() + " is "
                                    + cb.isChecked(), Toast.LENGTH_LONG).show();
                }
            }
        });

        // Cache the viewHolder object inside the fresh view
        convertView.setTag(viewHolder);

    } else {
        // View is being recycled, retrieve the viewHolder object from tag
        viewHolder = (ViewHolder) convertView.getTag();
    }

    HAM state = selectedhospital.get(position);

    viewHolder.name.setText(state.getName());
    viewHolder.home.setText(state.getAddress1()+"\r\n"+ state.getCity()+", "+state.getState()+" "+state.getZip());

    viewHolder.chk_hospitallist.setChecked(state.isSelected());

    viewHolder.chk_hospitallist.setTag(state);



    return convertView;
}
}

In this code, I am trying to hide and show RadioButton when Checkbox is checked or unchecked.Same time I am also want to add or remove selected/unselected checkbox value from an array. But when I am run this code it's not working properly. When I have selected one checkbox (from first view) the other view's radio button is got visible instead of first view. One more thing I also want select only one radio button (when I have selected more than 2 checkboxes).




Use ng-click to toggle checkboxes by altering element

I have a list of checkboxes generated using material design using the MUI CSS framework, the code below basically basically loops through an array and display 5 checkboxes.

The <i> tag contains either 'check_box' OR 'check_box_outline_blank' - if it shows 'check_box' this "checkbox" appears ticked, if it contains 'check_box_outline_blank' it will show the "checkbox" appearing as unticked.

Using ng-click I want to utilise the function toggleNetwork to basically toggle the <i> tag to contain either 'check_box' OR 'check_box_outline_blank'

// HTML

<div class="detail permissions" ng-class="{unfolded: role.showDetails != 'permissions'}" border-watch>
   <ul>
     <li ng-repeat="page in rule.pages" ng-click="toggleNetwork(this); ruleForm.$setDirty()">
      <span class="pull-left"><i class="check material-icons nomargin ">check_box</i></span>
      <i class="icon icon-"></i>
      <span class="permission-description"></span>
     </li>
   </ul>
</div>

// Javascript

$scope.toggleNetwork = function(this) {
  // change the `<i>` element to either 'check_box' OR 'check_box_outline_blank'
}




XML String missing Char

My application is reading a string from a xml-file and sets this string (Exsample: 200_006 Name_Text) as CheckBox.content. Everythings working fine except a missing char.

Somehow the first "_" is missing. The second one is shown.

Here's my code:

xReader = new XmlTextReader("Dummy.xml");
            while (xReader.Read())
            {
                switch (xReader.NodeType)
                {
                    case XmlNodeType.Text:
                        CheckBox newCBX = new CheckBox();
                        newCBX.Margin = new System.Windows.Thickness { Left = 3, Top = 2, Right = 3, Bottom = 2 };
                        newCBX.Content = xReader.Value;
                        wpnlLists.Children.Add(newCBX);
                        break;
                }
            }

Any ideas?




How do I correctly echo checkboxes in a PHP table?

I have a table which is full with data from my database. I am now trying to implement a delete feature on that table, I do have the correct syntax to echo checkboxes but I don't know how to format the line correctly so the corresponding checkbox aligns correctly with each row. Any ideas? (I currently have the line echo'd above the closing table tag. Which makes the boxes appear above the table)

    $query = "SELECT * FROM products";
    $result = mysqli_query($connection, $query);

    if ($result->num_rows > 0) 
    {
 echo "<table><tr><th>ID</th><th>Name</th><th>Description</th><th>Price</th><th>Cost Price</th><th>Stock</th><th>EAN</th><th>Delete Product</th></tr>";

 while($row = $result->fetch_assoc())
     {
     echo "<tr><td>" . $row["product_id"]
     . "</td><td>" . $row["product_name"]
     . "</td><td> " . $row["product_description"]
     . "</td><td> " . $row["product_price"]
     . "</td><td> " . $row["product_cost_price"]
     . "</td><td> " . $row["product_stock"]
     . "</td><td>" . $row["product_ean"]
     . "</td></tr>";
     echo '<input name="delete['.$row['product_id'].']" type="checkbox">';
     }
     echo "</table>";
    }
     else 
     {
     echo "0 results";
     }




Not able to use "onclick" and "onchange" functions while using custom checkboxes

When using customized checbox (i.e., icheck v1.0.1 from the website http://ift.tt/1VqAPUw), i am not able to use the "onclick" and "onchange" functions that i create manually. I have to use the custom "ifClicked" and "ifChanged" functions that the plugin provides.

Here is my code:-

<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="divchkBox">
  <input type="checkbox" id="extEmailChk" name="custEmailChkBox" onchange="foo()"/><br />

</div>
<script>
    function foo(){
        alert("hi");
    }
</script>
</body>
</html>

But the "foo" function doesn't get called. I have to use the custom "ifChanged" function.

<script>

    $('#divchkBox input').on('ifClicked', function (event) {
         alert("hi");
    });
</script>

I have tried to add the "onclick","onchange" functions in many ways but nothing works.

Can someone help?




how to remove the appended value if unchecked

here is my script i check the tr will append for view and i want to remove that when i click uncheck.

css 3 has to be removed because have unchecked it.

check and uncheck is happening from here

$("#jobSkills").on('change', '.selectPiSkill', function() {
    var count = $(this).attr('count');
    if (this.checked) {
        var title = $('#skill_' + count + '_title').val();
        var weightage = $('#skill_' + count + '_weightage').val();
        $('#PiSkills tr:last').after('<tr class="' + count + '"><td class="col-xs-4"><input value="' + title + '" readonly class="form-control text-center"></td><td class="col-xs-4"><input value="' + weightage + '" readonly class="form-control text-center" type="text"></td></tr>');
    } else {
        //unchecked remove tr
        $('#PiSkills tr.' + count).remove();
    }
});

<table id="PiSkills" class="table table-responsive" style="margin-bottom:5px">
    <tr>
        <th width="450"><input type="text" readonly value="Skill" class="form-control text-center">  </th>
        <th width="450"><input type="text" readonly value="Weightage(%)" class="form-control text-center"> </th>
    </tr>
</table>




dimanche 27 novembre 2016

Use standard inputs with angular material checkbox

Is there a way to us the normal input checkbox, for .NET forms? Or do I have to create my own directive/modify the material one to get this to work.

<md-checkbox ng-checked="$ctrl.checked = !$ctrl.checked">
    <input type="checkbox" name="test" value="1" />
</md-checkbox>

Obviously I could add the same ng-checked attribute to the input, however i feel this is a little unnecessary, I would have assumed a simple name attribute would automatically add in a hidden checkbox with a truthy value and automatically toggle the nested checkbox.




Android UI unit-tests: how to find dynamically added checkbox?

In my android app, I have a list of custom items (made of a clickable title + one checkbox without text). Those items are dynamically added.

How can I check one of those checkboxes in my unit tests using Espresso or a similar framework ?

I can't find how to get a reference to one of the checkboxes. Since they are dynamically added, I can't find them by id, like I usually do with static .xml views.




Check Box Style based on Theme

I have 2 themes, dark and light which will be applied on the of their respective buttons. For checkbox i have made 2 styles based on those two themes.

in XML

<CheckBox
    android:text="CheckBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/checkBox2"
    android:theme="?attr/check_style"/>

in attr.xml

   <attr name="check_style" format="reference"/>

in themes.xml

<?xml version="1.0" encoding="utf-8"?>
<resources  xmlns:android="http://ift.tt/nIICcg">
    <style name="dark" parent="AppTheme">
       <item name="check_style">@style/MyCheckBox1</item>

    </style>
    <style name="light" parent="AppTheme">
       <item name="check_style">@style/MyCheckBox3</item>
    </style>

</resources>

in styles.xml

<style name="MyCheckBox1" parent="Widget.AppCompat.CompoundButton.CheckBox">
    <item name="colorControlNormal">@android:color/black</item>
    <item name="colorControlActivated">@android:color/holo_orange_dark</item>
</style>
<style name="MyCheckBox3" parent="Widget.AppCompat.CompoundButton.CheckBox">
   <item name="android:drawable">@drawable/selector_checkbox</item>
</style>

in selector_checkbox.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://ift.tt/nIICcg">
    <item android:drawable="@drawable/apptheme_btn_check_on_focused_holo_light" android:state_checked="true" />
    <item android:drawable="@drawable/apptheme_btn_check_off_focused_holo_light" android:state_checked="false" />
    <item android:drawable="@drawable/apptheme_btn_check_on_focused_holo_light" android:state_pressed="true" />
    <item android:drawable="@drawable/apptheme_btn_check_off_focused_holo_light"/>


</selector>

For the style for checkbox in Dark, it works like a charm, but for the checkbox in light theme, once checkbox gets selected , only checked drawable is showing, no matter how many times if i deselect the checkbox.

Please help how to resolve it. NOTE : if i use the selector in xml like

   android:button="@drawable/selector_checkbox"

it works perfect.




How to Link checkbox to textfield in html/PHP

Is there any way one can link a checkbox to a textbox. For example

<form>
<table>
    <tr>
       <td><input name="databaseIDs[]" type="checkbox" value="49"/></td>
       <td><input type="text" name="first" value="First Input"/></td>
    </tr>
   <tr>
     <td><input name="databaseIDs[]" type="checkbox" value="50"/></td>
     <td><input type="text" name="first" value="Second Input"/></td>
  </tr>

<tr>
   <td><input name="databaseIDs[]" type="checkbox" value="60"/></td>
   <td><input type="text" name="first" value="Third Input"/></td>
</tr>
<tr>
  <td><input name="databaseIDs[]" type="checkbox" value="38"/></td>
  <td><input type="text" name="first" value="Fourth Input"/></td>
</tr>
</table>

</form>

As you can see, the checkbox is an array and each of the checkbox value is database id. What I am trying to do achieve is to update the database value where id is equal to the id of the checkbox which the user has ticked. For example if the user tick the first checkbox(with the value of 49), and the form is submitted, the database will update the value of in the database where the id is 49.




Select All checkbox Boxlabel not clickable in internet explorer

In the fiddle mentioned below, Select All checkbox is not clickable in internet explorer.It is working correctly in chrome and Firefox http://ift.tt/2g6wPuM.

I am using extjs version 6.0.1




samedi 26 novembre 2016

Values from unchecked checkboxes returning as "undefined"

I'm sure this has been addressed elsewhere, but I've read 20+ stackoverflow entries trying to find an answer, but all the ones I've read don't address this exactly and when I try to adopt proposed solutions, they just don't work. I'm having issues with unchecked checkboxes in Mad Libs returning a value of "undefined," so that the code below returns the following (if, for example, #check3 is checked and the other two are not):

In the end, their success can be contributed entirely to their undefined, undefined, dedicated [#noun-2 value, which is working just fine].

var $end = " In the end, their success can be contributed entirely to their " + $('#check1:checked').val() + ", " + $('#check2:checked').val() + ", " + $('#check3:checked').val() + " " + $('#noun-2').val() + ".";

Any idea of how I can return the values of only checked checkboxes? Do I need to write an if/else to make this happen?

Thank you.




How to display the value of hidden when checkbox is checked in PHP

Im having problem on how to get the value of the hidden input box once the checkbox is checked. here are my code.

<label class="control control--checkbox"><span>Additional</span>
   <input type="checkbox" name="apply[]" value=""/>
   <input type="hidden" name="option[]" value="1 bottle"/>
   <input type="hidden" name="cost[]" value="$20"/>
</label>
<label class="control control--checkbox"><span>Additional</span>
   <input type="checkbox" name="apply[]" value=""/>
   <input type="hidden" name="option[]" value="3 bottle"/>
   <input type="hidden" name="cost[]" value="$50"/>
</label>

My Php code:

<?php 
$options = $_POST['option'];
$costs = $_POST['cost']; 
$apply = $_POST['apply'];
if (isset($apply)) {
    foreach ($options as $option) {
    echo '<tr>';
    echo '<td>'.$option.'</td>';
    echo '</tr>';
    }
}
?>

It seems that the option of my php code is always two, i want only to display that was checked and dont display that are not.

can someone advise me on how can i solve this problem or any work around to get the same result?




unhide div on checkbox tick

I am trying to create a responsive navbar, so when you click a hidden checkbox the content unhides.

The problem is, I can't get the "checked" css to actually pick up and do anything.

Example to run here: http://ift.tt/2gtFloq

CSS Code:

#nav-hidden{background: red; display: none;}
#navigation-mobile{display:none;}

/* DESKTOP */
@media only screen and (max-width: 1200px) {
        #navigation-mobile {display: block;}
        #menu-toggle:checked ~ #nav-hidden {
            opacity: 1;
            height: 100vh;
            visibility: visible;
        }

        .label-toggle {
            cursor: pointer;
            display: block;
            float: right;
        }
}

HTML:

<div id="navigation-mobile">
  <input type="checkbox" id="menu-toggle">
      <label for="menu-toggle" class="label-toggle"></label>
    </input>
    <div id="nav-hidden">
        <ul>
            <li>test</li>
            <li>test</li>
        </ul>
    </div>
</div>




What is wrong with this vb wfa code?

what is wrong with this code for multi checkboxes in vb wfa it says it cant be converted to a boolian

If ch1.Checked & ch2.Checked = True Then
        score = score + 1
    End If




JavaScript multiple checkboxes - delimited list - store and parse

Hey I was wondering if anybody can help

Im a newbie and dont know any  javascript ! I need help for my caspio app.

The code below works I just need to get the second part I got the first part of storing the values of checked checkboxes in a database field as a comma de-limited list.

Now I need to read the comma de-limited list from the database and update the checkboxes accordingly

THANK YOU !!!

<SCRIPT LANGUAGE="JavaScript">
function concatenate()
{
var Resultfieldname = "CheckboxChoices";
var firstVirtual = 1;
var lastVirtual = 3;
var ResultString = "";
var virtualFieldName = "";

for (i=firstVirtual ;i<=lastVirtual; i++)
{
virtualFieldName = "cbParamVirtual"+i;
if (document.getElementById(virtualFieldName).checked) ResultString = ResultString + "," + document.getElementById(virtualFieldName).value;
}
Resultfieldname = "EditRecord"+Resultfieldname;
if (ResultString.length>0) ResultString = ResultString.substr(1);
document.getElementById(Resultfieldname ).value = ResultString;
}
document.getElementById("caspioform").onsubmit=concatenate;
</SCRIPT> 




CheckBox to limit a data validation list

I am wondering how to go about creating a data validation list that is limited by a Checkbox.

On one worksheet I have a table of the daily sales. Within that table I have data validation on a list of the sales person that gets tied to a sale.

On a second worksheet I have a list of employees that are used in the data validation from the first worksheet. A lot of these employees are no longer active. I want to add checkboxes for each employee to be checked or unchecked if active or not.

I would like these checkbxes to limit which employees show up in the data validation on the first worksheet.

Any suggestions???




angularjs and localstorage, toggle bouttom

I'm trying to make a application with Ionic Framework. I'm arrived on a point or I have to make a List of toggle buttom and I want to store if the buttom is checked or not, but I want to store then 1 by 1 not all in the same time. That look like that : http://ift.tt/2grWifj

When i press the first toggle or a other, my code checked every checkbox :/ not only 1. And in the second part when I leave the page and return on it that doesn't store if the checkbox is checked . here's my html code for the toggle:

<label class="toggle" ng-model="infoTeamCtrl" ng-click="addidMatch(match.data.fixtures[$index].homeTeamName, match.data.fixtures[$index].result.goalsHomeTeam, match.data.fixtures[$index].result.goalsAwayTeam, match.data.fixtures[$index].awayTeamName)">
    <input type="checkbox" ng-model="favorite.checked" ng-change="favoriteChange()" > 
    <div class="track">
        <div class="handle"></div>
    </div>
</label>

my controller look like that :

// Loads on page load/controller load
$scope.favorite["checked"] = localStorage.getItem("favorites");

// If never set
if($scope.favorite.checked == null) {
    $scope.favorite.checked = true;
}

// Save
$scope.favoriteChange = function() {
    localStorage.setItem("favorites", $scope.favorite.checked);
}

  $scope.addidMatch = function(infoMatchHomeTeam, infoMatchGoalHomeTeam, infoMatchGoalAwayTeam, infoMatchAwayTeam) {
    $i = $i +1
    $localStorage[$i] = {
      infoMatchHomeTeam, infoMatchGoalHomeTeam, infoMatchGoalAwayTeam, infoMatchAwayTeam
    }
  };

Thank for you comprehension.




Powershell as much checkboxes as a collection

With PowerShell, I made a form with three tabs. In one of them, I would have several checkboxes, and each one would be named by a collection of programs listed in the registry.

$Prog = Get-Item -Path "HKCU:\Software\MySoftware\EXE_list\"
$Programs = $Prog.property

I know how to make checkboxes. But from machine to an other, I won't have the same quantity of programs listed. So it could be up to 20 checkboxes.

So is there a way to do create checkboxes dynamically?

Thanks.




how to auto generate check box using js in adobe acrobat on click of a custom button in addon tool bar

I'm able to add a custom button to addon toolbar in adobe acrobat. But can someone help me how to generate a check box with auto-gen id and at flexible position on click of that added custom button.

Thanks in advance.




vendredi 25 novembre 2016

Cant Bind Panel with session in code behind, Collection was modified; enumeration operation may not execute

I have repeater control in that few repeater item bind with check box and few with Radio button while cheeked any radio button or check box I need to display that in one panel [ PanelRadio ] for radio button text and panel [PanelCheckBox] for check box option. but while I trigger a radio button I cant bind control for PanelCheckBox, for that am saving bind PanelCheckBox in one session and bind that in PanelRadio check event. but it shows ' Collection was modified; enumeration operation may not execute '

        CheckBox box = (CheckBox)sender;
        RepeaterItem item1 = box.NamingContainer as RepeaterItem;
        Repeater RptTopic = (Repeater)item1.NamingContainer;

        foreach (RepeaterItem item in RptTopic.Items)
        {
            CheckBox rbtn = (CheckBox)item.FindControl("custChkbx");
            Label disc = (Label)item.FindControl("CustTopic");
            if (rbtn.Checked)
            {
                Label lbl = new Label();
                lbl.Text = disc.Text;
                HtmlGenericControl div = new HtmlGenericControl("div");
                div.Controls.Add(lbl);
                Panel1.Controls.Add(div);
            }

        }
        Session.Add("DisOption", Panel1);
        if (Session["DisROption"] != null)
        {
            Panel z = (Panel)Session["DisROption"];
            foreach (Control child in z.Controls)    // Getting Error here
            {
                PanelCheckBox.Controls.Add(child);
            }
        }

** DisROption option session add while trigger a Check box event. **




Only allowing one checkbox to be checked for a userform

So I'm making a userform and I have to use make a group of mutually exclusive checkboxes or only allow the user to pick one. "But just use option buttons!" you cry. Two problems with that:

  1. I already have a separate set of option buttons in the userform (I believe you can somehow group them to allow multiple sets but I am unfamiliar with how to actually do this).

  2. My professor specifically wants checkboxes

so I attempted to solve this problem like this

If CheckBoxBar.Value = True And CheckBoxatm.Value = True Then
GoTo Here:
End If

If CheckBoxatm.Value = True And CheckBoxmmHg.Value = True Then
GoTo Here:
End If

If CheckBoxatm.Value = True And CheckBoxpsia.Value = True Then
GoTo Here:
End If

If CheckBoxBar.Value = True And CheckBoxmmHg.Value = True Then
GoTo Here:
End If

If CheckBoxBar.Value = True And CheckBoxpsia.Value = True Then
GoTo Here:
End If

If CheckBoxmmHg.Value = True And CheckBoxpsia.Value = True Then
GoTo Here:
End If

The here leads to a message box that re initializes the userform after the msg box says "You are only allowed to select one" with code like this

Here: MsgBox "You are only allowed to select on pressure unit."

The code "works" but it always goes to the Here: statement despite only picking one of the checkboxes. Can you spot anything wrong?

Thanks for the help!




Bootstrap switch looks all wrong

We are developing a web based tool and we are using bootstrap switches.

Our switch looks like this:

enter image description here

This is the HTML:

<td>
<input type="checkbox" id="planned" name="planned" class="switch">
</td>

The width of the <td> is set with the <th> and is 130px.

This is the JS:

$(".switch").bootstrapSwitch({
    onText: "Yes",
    offText: "No"
});

It looks like this in IE11 (all we have access to at work) but looks fine in firefox and chrome. Any ieas?




AngularJs bind an Array to an checkbox

i have the following JS and HTML:

$scope.loadInstallation = function (installationid) {
        $scope.currentInstallation = {};
        $scope.currentInstallation = $scope.installationList[installationid];;
        $scope.currentInstallationID = installationid;
    };
                          <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="installationmoduleIdList1">Module 1:</label>
                                        <div class="form-control">
                                            <label><input type="checkbox" id="installationmoduleIdList1" ng-model="currentInstallation.moduleIdList" /></label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="installationmoduleIdList2">Module 2:</label>
                                        <div class="form-control">
                                            <label><input type="checkbox" id="installationmoduleIdList2" ng-model="currentInstallation.moduleIdList" /></label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="installationmoduleIdList3">Module 3:</label>
                                        <div class="form-control">
                                            <label><input type="checkbox" id="installationmoduleIdList3" ng-model="currentInstallation.moduleIdList" /></label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="installationmoduleIdList4">Module 4:</label>
                                        <div class="form-control">
                                            <label><input type="checkbox" id="installationmoduleIdList4" ng-model="currentInstallation.moduleIdList" /></label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="installationmoduleIdList5">Module 5:</label>
                                        <div class="form-control">
                                            <label><input type="checkbox" id="installationmoduleIdList5" ng-model="currentInstallation.moduleIdList" /></label>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="form-group">
                                        <label for="installationmoduleIdList6">Module 6:</label>
                                        <div class="form-control">
                                            <label><input type="checkbox" id="installationmoduleIdList6" ng-model="currentInstallation.moduleIdList" /></label>
                                        </div>
                                    </div>
                                </div>
                            </div>

And an JSON, which look something like this:

currentInstallation =
{
  "id":"1",
  "moduleIdList": [ "1", "2" ]
}

The "1" in the "moduleIdList" equals "true" in the HTML "Module 1:" Checkbox, the Problem is, I don't know, how to bind the "moduleIdList" to the Checkboxes, so that when there's a "1" in "moduleIdList" the Checkbox is checked and when someone uncheck it, the "1" will be deleted out of the Array

Hope you can understand my problem, I'm glad for any help!

Greetings, Simon




Have input checkbox toggle checked/unchecked in AngularJS 1.x

I am still new to AngularJS, I am trying to have a simple function that will toggle a checkbox on/off when clicked. So a clicked li element in the code below will either set that checkbox to on or off.

Can anyone suggest the best way to do this using AngularJS, I know jQuery would be simple but i'm trying to do this in the Angular way.

my html template

    <ul>
        <li ng-repeat="page in rule.pages" ng-click="toggleNetwork(page.id); ruleForm.$setDirty()">
            <span class="pull-left"><i class="check material-icons nomargin"></i></span>
        </li>
    </ul>   

my Controller scope logic code

$scope.toggleNetwork = function(networkId) {
   // function called when checkbox clicked

}




Nesting checkboxes hack

i've tried to nest the Checkboxes hack but it didn't quit work the way i expected... i wanted to show and hide Divs or sections depending on which checkbox is selected. Here is the Link to the website, maybe somebody can point out what i am doing wrong...

i tested the checkboxes without nesting them and they work properly...

Ps. when i inspect the Code and resize it to mobile version it works better than the Desktop version...

http://ift.tt/2ffwLcV




Permanently modify checkbox value dynamically via javascript before php form submission

In order to submit a new event along with the user-generated event-date (generated via select/drop-down element), the corresponding checkbox has to be selected after creating/selecting the event-date and converting it to ISO formatted date-string (dt_iso).

This is the code I am executing at the end of the onchange event's function call (for the checkbox having id cbx_e) in order to dynamically modify the checkbox value after selection. But the code does not execute correctly due to undecipherable mistake.

var dt_repl = ";" + dt_iso + ";";
document.getElementById('cbx_e').options[document.getElementById('cbx_e').selectedIndex].value = document.getElementById('cbx_e').options[document.getElementById('cbx_e').selectedIndex].value.replace(";;", dt_repl);

I have attempted the following code also, but no improvement as the code executes erroneously:

var dt_repl = ";" + dt_iso + ";";
document.getElementById('cbx_e').options[document.getElementById('cbx_e').selectedIndex].value.replace(";;", dt_repl);

Also I need advice on whether the checkbox value modified via javascript is really possible to be passed via $_POST variable during form submission.

Note : As the checkbox value for an non-dated event has absent date-field before its date is selected via drop down, I have set its default field value to ";;", and later I want to modify it to something like ";2016-11-26T15:00:00+05:30;" which is the ISO date string.

Thanks.




Changing checkbox appearance to button

I am using a checkbox as a toggle switch (ON-OFF Button) by changing its appearance to Button using checkbox.appearance() property. When i run the vb.net application, the checkbox turns into a button only after the first click. Is it possible to change the appearance of the checkbox to button as default? I also want the button to Popup when the user clicks "ON". I have tried changing the appearance using "Flat Style" property, but it doesn't work.




VBA Userform to select checkboxes and extract data based on their filter

I currently have a worksheet labelled "Register".

I have this code whereby it extracts this worksheet and provides the 'save as' option to a folder.

The worksheet has headers and these headers have filters. The columns: O-U are labelled as follows:

Column O: Marston Green

Column P: Test Engineering

Column Q: West Hartford

Column R: Singapore

Column S: Xiamen

Column T: Neuss

Column U:Dubai

The data within these columns are of True/False only and the data begins on row 6.

I have created a userform interface that when ran allows the user to select a location out of the above via checkboxes and there are also three option buttons: True, False, Both.

What I'm trying to do with this userform interface is as follows:

1)

When you select a location and select True. It will filter True for that location and extract the worksheet.

When you select a location and select False it will filter False for that location extract the worksheet.

When you select a location and select BOTH true and false it will just extract the worksheet.

If one location doesn't have any True/False options and the user selects True/False and presses 'extract' - a notification will come up stating "No true/false options for this location- please amend search".

2)

The extracted worksheet doesn't have filters function on. So there are no filters on the extracted worksheet.

The current coding I have within the userform:

Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdClear_Click()
'Clear the form
    For Each ctl In Me.Controls
    If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then
        ctl.Value = ""
    ElseIf TypeName(ctl) = "CheckBox" Then
        ctl.Value = False
    End If
   Next ctl
End Sub
Private Sub cmdExtract_Click()
If MsgBox("                      Please Confirm", vbYesNo) = vbNo Then Exit Sub
Application.DisplayAlerts = False
Dim wb As Workbook, InitFileName As String, fileSaveName As String

    InitFileName = ThisWorkbook.Path & "\ Extracted_Register_" & Format(Date, "dd-mm-yyyy")

    Sheets("Register").Copy
     ' or below for more than one sheet
     ' Sheets(Array("Output", "Sheet2", "Sheet3")).Copy

    Set wb = ActiveWorkbook

    fileSaveName = Application.GetSaveAsFilename(InitialFileName:=InitFileName, _
    filefilter:="Excel files , *.xlsx")

     With wb
        If fileSaveName <> "False" Then

            .SaveAs fileSaveName
            .Close
        Else
            .Close False
            Exit Sub
        End If
    End With


MsgBox ("Extraction Completed")
Unload Me
Application.DisplayAlerts = True
End Sub

Private Sub UserForm_Click()

End Sub




Sending multiple checkbox checked values to Action Method without Submit button

how to call the Action Method and send the selected IDs to action method when multiple checkboxes are checked without binding to model and submit button in MVC4. Please guide me. Thanks in advance




ASP.net: how to store array of day checkboxes into MSSQL?

Good day. MSDN says that bit MSSQL datatype mapping onto bool C# datatype. ASP.net map checkbox onto bool, if i currently understand. And i need to store set of checkboxes states (bool[]).

Constants.cs contains this line:

public static string[] Days => new string[] { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" };

View.cshtml contains this:

@foreach (var day in Constants.Days)
{
    <div class="form-group">
        <label class">@day</label>
        <input name="Days" type="checkbox" class="checkbox-inline" />
    </div>
}

And this, i think, will be mapped on bool[]. But here is no possible ways to store bool array in db? Or how to store set of checkboxes states in Db?




jeudi 24 novembre 2016

On check box click get the table Row ID - Objective c

I am new to objective C. I have a checkbox (its a image) inside a table view. when ever this checkbox is clicked i want get the row (table row id) of the clicked check box.

My application looks like this

enter image description here

objective c I tried like this but it always gives me the first id

- (void)checkBoxBtnPressed:(id)sender {

    UIButton *btn = (UIButton *)sender;
    PickupTicketsItemObject *item = [ticketList objectAtIndex:btn.tag];

    NSLog(@"item_select %@", item.getTicket_id);
    if ([item isSelected]) {
        [btn setBackgroundImage:[UIImage imageNamed:@"icon_uncheck"] forState:UIControlStateNormal];
        [item setIsSelected:NO];
    }else {
        [btn setBackgroundImage:[UIImage imageNamed:@"icon_check"] forState:UIControlStateNormal];
        [item setIsSelected:YES];
    }

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {


    NSLog(@"selected index : %@", indexPath);
    NSLog(@"selected index : %ld", (long)indexPath.section);

    //Check if assigned to user

    PickupTicketsItemObject *item = [ticketList objectAtIndex:indexPath.section];
    NSLog(@"selected index : %@", item.ticket_id);
    NSLog(@"selected index : %@", item.ticket_assignedto);

    //Print all user defaults key and value
    //NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]);

    // get the display name from user defaults
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];

    NSString *displayName;
    NSString *AgentName;
    if ([userDefaults objectForKey:@"DisplayName"] != nil) {
        displayName = [userDefaults objectForKey:@"DisplayName"];
    }else {  displayName = @"Not defined";  }

    AgentName = [@"Agent : " stringByAppendingString:displayName];

    NSLog(@"Display Name  : %@", displayName);
    NSLog(@"Agent Name    : %@", AgentName);
    NSLog(@"Assigned Name : %@", item.ticket_assignedto);


    // ticket is already assigned to agent, send to ticket details page
    if ([item.ticket_assignedto isEqualToString:AgentName]) {
        NSLog(@"Ticket already assigned to this User.");
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        TicketDetailViewController *ticketDetailViewController = [storyboard instantiateViewControllerWithIdentifier:@"TicketDetailViewController"];
        ticketDetailViewController.ticket_id = item.ticket_id;

        [kNavigationController pushViewController:ticketDetailViewController animated:YES];
        [kMainViewController hideLeftViewAnimated:YES completionHandler:nil];

    } else{
        NSLog(@"Ticket not assigned to this User.");
        // Ask the user to pick the ticket.

        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        SinglePickUpViewController *singlePickUpViewController = [storyboard instantiateViewControllerWithIdentifier:@"SinglePickupVC"];
        singlePickUpViewController.ticket_id = item.ticket_id;
        [kNavigationController pushViewController:singlePickUpViewController animated:YES];
        [kMainViewController hideLeftViewAnimated:YES completionHandler:nil];

    }

}

Can some one help me to get the clicked checkboxes table row id. tnx




How do we set "True" or "False" strings to the response of a checkbox for its checked or unchecked state respectively in html?

Hi I'm currently using radio buttons to pass True or False as a string in my project. I would like to change it to a checkbox that returns the same values, i.e "True" or "False" (based on whether the checkbox is checked or unchecked) so that I'm not forced to change the condition everywhere else in my project.

Access
Do not access

Any suggestions for the same?




After closing a popup window and check another checkbox previous checkbox gets checked as well

I have a weird thing going on when opening a popup window..Here are the steps and the relative code

1) Check a checkbox from the row

2) Click on Edit button

The code for the edit button is

$(".myEdit").click(function () {
    GetSelectedIDs(this.id);
})
function GetSelectedIDs(btn) {
    var idsToSend = [];
    var grid = $("#Customer-Grid").data("kendoGrid")
    var ds = grid.dataSource.view();

    for (var i = 0; i < ds.length; i++) {
        var row = grid.table.find("tr[data-uid='" + ds[i].uid + "']");
        var checkbox = $(row).find(".checkbox");
        if (checkbox.is(":checked")) {
            idsToSend.push(ds[i].CustomerID);
        }
    }
    switch (btn) {
        case "delete": {
            if (idsToSend.length > 0) {
                Confirmation("delete", idsToSend);
            }

        }
            break;
        case "edit": {
            if (idsToSend.length > 1) alert("You can only edit one record at a time");

            else if (idsToSend.length == 0) alert("Need to select at least one record");

            else {
                HomeStorage.Keys.StringOfIDs = idsToSend;
                HomeStorage.Keys.CustomersID = idsToSend;
                CustomerUpdateEditor();
            }
        }
            break;
    }
}

Here is the CustomerUpdateEditor

function CustomerUpdateEditor() {
    $("#showCustomerEdit").append("<div id='window'></div>");
    var myWindow = $("#window").kendoWindow({
        position: {
            top: 100,
            left: "30%"
        },
        width: "40%",
        //height: "36%",
        title: "Customer",
        content: "/Customer/CustomerEditor",
        modal: true,
        actions: [
            "Close"
        ],
        close: function (e) {
            $("#window").data("kendoWindow").destroy();
        }
    }).data("kendoWindow");
    myWindow.open();//myWindow.center().open();
    HomeStorage.Keys.AddOrEdit = "Edit";
    GetStates();
}

and the button that closes this popup is

$("#btnClose").click(function () {
    ClearFields();
    CloseTheWindow();
    GetCustomerGridData();
});

The CloseTheWindow function is

function CloseTheWindow() {    
    $("#window").data("kendoWindow").destroy();
    localStorage.clear();
}

3) Now that the popup is closed and the CustomerGrid is refreshed, I check a different checkbox, well now what happens is that once I check the next checkbox the previous checkbox is checked as well and it doesn't make sense that it would happen, it shouldn't happen.

This is the Customer-Grid

function LoadCustomerGrid(newData) {
    $("#Customer-Grid").kendoGrid({
        dataSource: {
            data: newData
        },
        schema: {
            model: {
                CustomerID: { type: "number" }
            }
        },
        filterable: {
            mode: "row"
        },
        columns: [
            {
                title: "<input id='checkAll', type='checkbox', class='check-box' />",
                template: "<input name='Selected' class='checkbox' type='checkbox'>",
                width: "30px"
            },
            {
                field: "CustomerID",
                title: "CustomerID",
                hidden: true
            },
        {
            field: "LastName",
            title: "Last Name",
            filterable: {
                cell: {
                    showOperators: false,
                    operator: "contains"
                }
            }
        },
        {
            field: "FirstName",
            title: "Name",
            filterable: {
                cell: {
                    showOperators: false,
                    operator: "contains"
                }
            }
        },
        {
            field: "Phone",
            title: "Phone",
            filterable: {
                cell: {
                    showOperators: false,
                    operator: "contains"
                }
            }
        },
        {
            field: "Address",
            title: "Address",
            filterable: {
                cell: {
                    showOperators: false,
                    operator: "contains"
                }
            }
        },
        {
            field: "City",
            title: "City",
            filterable: {
                cell: {
                    showOperators: false,
                    operator: "contains"
                }
            }
        },
        {
            field: "Zip",
            title: "Zip",
            filterable: {
                cell: {
                    showOperators: false,
                    operator: "contains"
                }
            }
        }
        ],
        scrollable: true,
        sortable: true,
        pageable: {
            pageSize: 20
        },
        selectable: "row",
        height: $("#Customer-Grid").closest(".col-height-full").height() - 60,
        change: function (e) {
            // Function call goes here
            var detailRow = this.dataItem(this.select());
            var optionID = detailRow.get("CustomerID")
        }
    });
}




C# WinForm how to link a command to a dynamically made checkbox?

I am currently making a flash drive lock (it hides/unhides folders) in C# Winform. I've already ready made it the C# Console, so i have most of the commands needed. I have a dir command getting the paths to the all the folders

public static dynamic getFolder()
    {
        Dictionary<dynamic, List<dynamic>> dictionary = new Dictionary<dynamic, List<dynamic>>();

        int selector = 1;
        bool isHidden;
        foreach (string folderPath in Directory.GetDirectories(Form2.driveLetter))
        {
            List<dynamic> data = new List<dynamic>();
            string folderName = folderPath.Substring(3);
            if (folderName == "#") { continue; }
            if (folderName == "System Volume Information") { continue; }
            isHidden = Status(folderPath);

            data.Add(folderPath.Substring(3, folderPath.Length - 3));
            data.Add(isHidden);
            data.Add(folderPath);

            dictionary.Add(selector, data);
            selector++;
        }

        dictionary.Add(selector++, Vault());
        return dictionary;
    }

then I have the Dictionary piped into a different method that gets the names of the folder (and hidden state) then turns them into checked boxes; if the folder is hidden, then the box is checked, and if it isn't, then its unhidden (I will in time make this part more efficient)

private void CreateBox(Dictionary<dynamic, List<dynamic>> dictionary)
    {
        int y = 0;
        int z = 0;
        CheckBox box;
        for (int x = 1; x < dictionary.Count(); x++)
        {
            List<dynamic> folder = dictionary[x];
            box = new CheckBox();
            box.Text = folder[0];
            box.AutoSize = true;
            box.Checked = folder[1];

            if (y == 180)
            {
                box.Location = new Point(370, 39 + z);
                z += 20;
            }
            else
            {
                box.Location = new Point(198, 39 + y);
                y += 20;
            }
            this.Controls.Add(box);
            CheckBoxes.Add(box);
        }
    }
        //File.SetAttributes(folderPath, FileAttributes.Hidden);

        //File.SetAttributes(folderPath, FileAttributes.Normal);

!http://ift.tt/2ga1ipr

!http://ift.tt/2ga82Uq

How do I link a SetAttributes command to the check box, so when the box is checked, it hides the respective folder and when the box is unchecked, it unhides the folder