jeudi 30 juin 2016

How to pass an array from laravel to ajax

I have an array of fonts which i displaying in the page using blade templates @foreach like this

       @foreach($data as $fonts)
            <li class="abc">

                <div class="am-actions"><a href="" class="add-font"><span><i class="icon add"></i></span></a></div>
                 <a href="#" class="details">Grumpy wizards make toxic brew for the evil Queen and Jack.</a>
                </div>
                <div class="am-font-details">
                    <div class="am-font-name">{!! $fonts['font_name'] !!}</div> 
                    <div><?php echo $count = count($fonts['variants']); ?> Styles</div>
                </div>
                <div class="am-font-options">
                    <h4>SELECT VARIANTS TO INCLUDE:</h4>
                    <ul>
                        @foreach($fonts['variants'] as $variants)

                          <li><label><input type="checkbox">

                          


                          </label></li>

                        @endforeach

                    </ul>
                    <h4>LANGUAGE/SCRIPT TO INCLUDE:</h4>
                    <ul>
                        @foreach($fonts['subsets'] as $subsets)

                         <li><label><input type="checkbox"> </label></li>

                        @endforeach
                    </ul>
                </div>
            </li>
        @endforeach

as you can see i use @foreach for variants and languages inside the main loop the variants and langauges is listed with checkbox so the user can selected their choice and add. on the add the selected variants and languages with the main font array details should be passed through ajax please help me :-(




Pass checked multiple images from one activity to another

I have a custom listview with checkbox imageview and textview and there is a button below listview. On clicking of that button i have to pass all the checked item details to another activity and show in other listview. I am able to pass selected value but not able to pass images. Images are in drawable folder. Please help me thanks.

Here is the code:

subscribe.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            String data = "";
            ArrayList<Item> stList = ((OurServiceAdapter) nAdapter)
              .getAllData();

            for (int i = 0; i < stList.size(); i++) {
                Item singleStudent = stList.get(i);
                if (singleStudent.isCheckbox() == true) {
                       name.add(singleStudent.getName().toString());
                       img.add(singleStudent.getImage());
                 data = data + "\n" + singleStudent.getName().toString();



                }

               }
              // byte[] imgs = singleStudent.getImage();
               Intent intent = new Intent(ActivityOurServices.this, ActivityServicesForm.class);
               intent.putStringArrayListExtra("key", name);
               //intent.putIntegerArrayListExtra("img", img);
               startActivity(intent);



        }
    });
}




Why my checkbox value not set to true although it is checked?

I have a list of checkbox that represents column names. The user needs to pick which column that he/she wants to be displayed in datagridview. There is also a checkbox in header that when clicked will set that all the checkbox that represents column names will be selected automatically. The problem is at condition if (cell.Value != null). The cell.Value is set to false. So i cannot get the column names into allSelectedColumn. Why is this happening and how can i solve them. Thank you in advance.

    string selectedColumn, allSelectedColumn;
    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        allSelectedColumn = "";
        if (e.RowIndex >= 0)
        {
            int intIndexColumnVal = e.ColumnIndex;
            if (intIndexColumnVal == 2)
            {
                string selectedColumnSingle = Convert.ToString(dataGridView1.Rows[e.RowIndex].Cells[2].Value);
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    DataGridViewCheckBoxCell cell = row.Cells[0] as DataGridViewCheckBoxCell;
                    if (cell.Value != null)
                    {
                        if (cell.Value == cell.TrueValue)
                        {
                            selectedColumn = Convert.ToString(dataGridView1.Rows[row.Index].Cells[2].Value);
                            allSelectedColumn = allSelectedColumn + selectedColumn + ",";
                            selectedColumn = "";
                        }
                    }
                }

                if (allSelectedColumn == "")
                {
                    allSelectedColumn = selectedColumnSingle;
                }

                Form2 f2 = new Form2(dataTable, allSelectedColumn);
                f2.ShowDialog();
            }
        }
    }

This is the code when the user checked the header checkbox.

    private void checkboxHeader_CheckedChanged(object sender, EventArgs e)
    {
        for (int i = 0; i < dataGridView1.RowCount; i++)
        {
            dataGridView1[0, i].Value = ((CheckBox)dataGridView1.Controls.Find("checkboxHeader", true)[0]).Checked;
        }
        dataGridView1.EndEdit();
    }




PHP multiple checked checkboxes from database

I am trying to generate a form with multiple checkboxes from a database. Right now only the last entry from the array is showing up. If there is supposed to be only one thing checked it works, but for more than one, only the last entry in the array shows up as checked. Any help would be greatly appreciated. Thanks!

<?php
include "DBconnect.php";

$staffId = $_REQUEST["ID"];

$query=" select listCode from staffLabels
        where staffId = $staffId";

$result=$mysql->query($query);
while($row=$result->fetch_assoc()){
    //in_array ()check if value is in array

    $b_checked='';
    $d_checked='';
    $x_checked='';
    $f_checked='';
    $c_checked='';
    if($row['listCode'] =="b") {$b_checked='checked';}
    elseif($row['listCode'] =="d") {$d_checked='checked';}
    elseif($row['listCode'] =="x") {$x_checked='checked';}
    elseif($row['listCode'] =="f") {$f_checked='checked';}
    elseif($row['listCode'] =="c") {$c_checked='checked';}


}
echo '<input type="checkbox" name="listCode[]" value="b" '.$b_checked.' >b';
echo '<input type="checkbox" name="listCode[]" value="d"  '.$d_checked.' >d';
echo '<input type="checkbox" name="listCode[]" value="x"  '.$x_checked.' >x';
echo '<input type="checkbox" name="listCode[]" value="f"  '.$f_checked.' >f';
echo '<input type="checkbox" name="listCode[]" value="c"  '.$c_checked.' >c<br /><br />';
?>




Auto select and collect checkbox values in array

I'm having a problem with setting (checking) and fetching array of data from view to my model. Let me explain my problem further with code.

This is my controller where i provide working days

$scope.workDays = [
                {name: 'Monday', value: 1},
                {name: 'Tuesday', value: 2},
                {name: 'Wednesday', value: 3},
                {name: 'Thursday', value: 4},
                {name: 'Friday', value: 5},
                {name: 'Saturday', value: 6},
                {name: 'Sunday', value: 7},
            ]
$scope.selectedDays = [1,3,4,6];

Then i render those check boxes with ng-repeat in my HTML

<label>Working days</label>
<div class="checkbox">
     <label ng-repeat="w in workDays" ng-model="myData">
            <input type="checkbox" ng-value="w.value" >
            
     </label>
</div>

1. Question: How to check checkboxes based on value $scope.selectedDays?

The second problem that i have is once i try to fetch new selected values i always get empty array

So my controller looks like this

$scope.myData = [];
console.log($scope.myData);

Then i select and deselect some checkboxes, how ever, console log reports empty array []

I hope you guys can help me. If you need any additional informations please let me know and i will provide. Thank you!




Multiple Checkboxes

so I have been working on this program in excel which basically runs a new command or macro to specific columns depending on which checkbox or boxes are being checked on a Userform. The problem I am running into is that I have gotten to 2 checkboxes performing a new macro when checked, thanks to some help from this site, but now I cant figure out how to get more than 2 to run a new macro or command.Any help would be great thank you! The code I have been running is like this:

     Private Sub cbs_Check()
With Me
 If .cb300Bolt And .cbSCH80 And .cbXray Then
    ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[2])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

ElseIf .cb300Bolt And .cbSCH40 And .cbXray Then
 ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

                     ElseIf .cb300Bolt Then
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-11])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select

                   ElseIf .cbSCH80 Then
                Range("P7").Select
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C)+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[4])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select

                 ElseIf .cbXray Then
                Range("P7").Select
                 ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-2])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select

                ElseIf .cbSCH40 Then
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select


            Else
                Range("P7").Select
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-11])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select
    End If

    If .cbXray And .cbSCH40 Then
     ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Sheets("SCH 40 Calculator").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select
    ElseIf .cbXray And .cbSCH80 Then
     ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[2])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[4])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cbXray And .cbCongestedArea Then
Range("P7").Select
    ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-2])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[3])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cbXray And .cb300Bolt Then
        ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-2])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cb300Bolt And .cbSCH40 Then

ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cb300Bolt And .cbSCH80 Then
    Sheets("SCH 40 Calculator").Select
Range("P7").Select
ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C)+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

   ElseIf .cbCongestedArea And .cb300Bolt Then
       Sheets("SCH 40 Calculator").Select
ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C)+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[3])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cbCongestedArea And .cbSCH80 Then
ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C)+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[5])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cbCongestedArea And .cbSCH40 Then
      ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[3])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

    ElseIf .cb300Bolt And .cbSCH40 And .cbXray Then
      ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select






           ElseIf .cbXray Then
                Range("P7").Select
                 ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-2])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select
            ElseIf .cbSCH40 Then
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select
            ElseIf .cbCongestedArea Then
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-11])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[3])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select

            ElseIf .cbSCH80 Then
                Range("P7").Select
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C)+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[4])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select
            ElseIf .cb300Bolt Then
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-11])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[6])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select




            Else
                Range("P7").Select
                ActiveCell.FormulaR1C1 = _
                "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-11])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
                Range("P7").Select
                Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
                Range("P7:P30").Select

    End If



End With

End Sub




Rails 4: HATMB Checkbox issue -- nil error

I have a HABTM relationship between learning objectives and tasks. I was able to implement checkboxes via http://ift.tt/29g2W9Z. However, I am running into an issue when all the boxes are unchecked. See blow

form:

<% for task in Task.all %>
<%= check_box_tag "tlo[task_ids][], task.id, @tlo.tasks.include?(task) %>
<%= task.name%>
<%end%>

TLO controller:

    def update
     params[:tlo][task_ids] ||= []
     respond_to do |format|
       if(@tlo.update)
        format.html {redirect_to @tlo}
       end
      end
   end

Yes, task_ids: [] in my permitted params. When looking in the log its says "undefined method [] for nil:nilClass." Some resources say because on a form with only checkboxes with none selected won't submit anything? Does anyone have suggestions for a workaround?




checked form redirect with javascript and css label styling

I wish to make a css styling of a form, with a href="#url" redirect when the checkbox is checked. I managed to make the styling work, but the javascript redirect isn't working.

So basically, I want to have a form where I can style it with a "fake" or "artificial" checkbox, that will respond to a javascript redirect code, which redirects to another http:// url.

CSS:
/* <-- hide the default checkbox */

label input {
  display: none;/* <-- hide the default checkbox */
}

label {
        margin-bottom: 5px;
    margin-left: 10px;
    font-size: 13px;
}

label .checkbox {/* <-- style the artificial checkbox */
  height: 15px;
  width: 15px;
  border: 1px solid #9c9c9c;
    border-radius:2px;
  display: inline-block;
  position: relative;
  margin-right:10px;
}
[type=checkbox]:checked + .checkbox:before {/* <-- style its checked state..with a ticked icon */
  content: '\2714';
  position: absolute;
  top: -1px;
  left: 3px;
  font-size:20px;
}

.studylicense {
    color: #929292;
    margin-bottom:2px;
    position:absolute;
}

HTML:
<div><label>
  <input style="display:none;" type='checkbox' name="studentRedirect" class="checkbox">
<div class="study checkbox"></div><span class="studylicense"><strong>Studielicens <img class="help-icon" alt="" src="images/help.png"></strong></span></label>
<input style="display:none;" type="checkbox" name="studentRedirect"></div>


                        <input style="display:none" type="submit" name="Send" value="Opret gratis konto" class="btn btn-success" />
                        <span class="sign-up"><a class="supportButton btn btn-success " onclick="if (validator(document.forms['trial'])) document.forms['trial'].submit();" href="javascript:;">
                                        Opret gratis konto</a></span>


                                        <%
                                if trialSignedUp then
                            %>
                            <div id="submitconfirm" class="alert alert-success">
                    Velkommen til <span class="defgoBlue">defgo</span>, vi har sendt en email indeholdende dit gratis login og password</div>

JAVASCRIPT:
  if (theForm.studentRedirect.checked == true)
  {
    self.location="/dk/kontakt/studerende.asp"
    return (false);
  }




Android : How to disable one item in AlertDialog with MultiChoiceItems

I create a dialog with following code :

final CharSequence[] items        = {" One ", " Two ", " Three "};

AlertDialog dialog = new AlertDialog.Builder(this)
            .setTitle("Title1")
            .setMultiChoiceItems(items, null, null)
            .setPositiveButton("CLOSE", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    Log.e("1k", "count : " + ((AlertDialog) dialog).getListView().getChildCount());

                }
            }).show();
    ListView lw = dialog.getListView();
    //lw.getChildAt(0).setEnabled(false);
    Log.e("1k", "count : " + lw.getChildCount());

This creates a dialog. When I click on the "CLOSE" button I can see an output of "3" in the logs. So far so good, "items" array has 3 Strings in it.

The last line of code, which gets invoked after "show()", gives me "0" in the logs.

What I want to do is disabling the first item in the list, but this code throws a NullPointerException because "getChildAt(0)" returns null :

dialog.getListView().getChildAt(0).setEnabled(false);

How can I disable the first Item in the dialog's list ?

(and why does getChildCount() ..

.. return 0 instead of 3 when invoked after show() ?

.. return 3 as expected in onclick of PositiveButton ? )




how to make checkbox checked by default in angularjs

I have two address fields. If current address is same as permanent address user will select checkbox then the value from current address field will be copied to permanent address field and permanent address field will gets disabled automatically.

But my issue is when i refresh the page or logout and login again then the checkbox become unchecked so the permanent address field become enable.

HTML :

<div class="form-group col-sm-6" ng-class="{ 'has-error': pForm.caddress.$dirty && pForm.caddress.$error.required }">                          
                                    <label class="control-label l_font" for="address">Current Address*</label>
                                    <textarea class="form-control" type="text" name="caddress" placeholder="Current address" ng-model="caddress" ng-disabled ="!pEditMode"  ng-required = "true" ></textarea>
                                    <span ng-show="pForm.caddress.$dirty && pForm.caddress.$error.required" class="help-block">Current Address is required</span>                                
                                </div>


                                <div class="form-group col-sm-6" ng-class="{ 'has-error': pForm.paddress.$dirty && pForm.paddress.$error.required }">
                                    <label class="control-label l_font" for="address">Permanent Address*</label>
                                       <input type="checkbox" ng-model="sameAddrres" ng-checked="copyAddress()" ng-disabled ="!pEditMode" />
                                    <i class="inside">Select if Permanent address is same as Current address</i>

                                    <style>
                                    .inside 
                                        {
                                            font-size: 12px;
                                        }
                                    </style>
                                    <textarea class="form-control" type="text" name="paddress" placeholder="Permanent address" 
                                              ng-model="paddress" ng-disabled ="!pEditMode || sameAddrres" ng-required = "true" ></textarea>
                                    <span ng-show="pForm.paddress.$dirty && pForm.paddress.$error.required" class="help-block">Permanent Address is required</span>
                                </div>

Controller :

$scope.copyAddress = function(){

            if($scope.sameAddrres == true){

                $scope.paddress = $scope.caddress;
            }            
        };

can anyone please help me its very urgent.




checkbox select all delete issue

i have checkboxes in custom list view and i have two seperate buttons one to select all and another to delete but i have big issue in it if i select one checkbox and select delete it works.but if i select all and delete it delete few of the data in lists ,for example i have 50 sms in list view once i select all and delete it delete few sms and again i press delete it delete another few like this..suggest some solutions

     sel.setOnClickListener(new View.OnClickListener() {
        @Override

     public void onClick(View v) {

     for (int i = 0; i <sms.size() ; i++) {

       if(sms.get(i).getChecked() == false ) {
                    sms.get(i).setChecked(true);
                }else if(sms.get(i).getChecked()==true) {
                    sms.get(i).setChecked(false);
                }


            }
            ((datalist)mlistView.getAdapter()).notifyDataSetChanged();
        }
    });
             del.setOnClickListener(new View.OnClickListener() {
        @Override

      public void onClick(View v) {


            for(int i=0; i<sms.size(); i++){
                if(sms.get(i).getChecked() == true){
                    sms.remove(i);
                }
            }


            ((datalist)mlistView.getAdapter()).notifyDataSetChanged();

        }




C# - HTTP POST request from with checkboxes

Trying to write a c# app to sign me up for all these newsletters, I have used HTTPFox to analyze the HTTP requests and construct the right POST parameters but WebRequest is throwing a 403 forbidden. I've done this successfully with simple forms but the huge # of controllers and the checkboxes are heavy.

HTTPFox Output:

POST data:

Parameter: Value
    _account_id 737
    _table_id   1
    _email_field    1.email
    _dedupe 1
    _static_update  1
    _rp http://ift.tt/29f7FbT
    _list_id    12
    _list_id    1
    _list_id    8
    _list_id    5
    _list_id    4
    _list_id    10
    _list_id    14
    _list_id    6
    _list_id    13
    _list_id    2035
    _list_id    7091
    _list_id    318
    _list_id    2
    _list_id    7294
    _list_id    317
    _list_id    8702
    _list_id    7298
    _list_id    7295
    _list_id    7297
    _list_id    10158
    _list_id    6419
    7.title Mr
    7.first_name    fname_redacted
    7.surname   sname_redacted
    1.email redactedg@outlook.com
    7.company   cname_redacted
    7.position  Analyst
    7.add1  23 liverpool road
    7.add2  
    7.add3  
    7.add4  liverpool
    7.add5  Bedfordshire
    7.postcode  l59uh
    7.telephone 1519838474
    7.sector    Accountants
    7_employees Less than 25
    7.turnover  
    7.registered_by 
    7.audit_question    

Headers:

Request_header: Value
(Request-Line)  POST /s/ HTTP/1.1
Host    newsco.msgfocus.com
User-Agent  Mozilla/5.0 (Windows NT 6.3; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-US,en;q=0.5
Accept-Encoding gzip, deflate, br
Referer http://ift.tt/297YUwP
Connection  keep-alive
Content-Type    application/x-www-form-urlencoded
Content-Length  752

C#:

    WebRequest request = WebRequest.Create("http://ift.tt/297YOoS");
    request.Method = "POST";
    string postData = "email=redacted%40outlook.com";
    postData += "&_account_id=737";
    postData += "&_table_id=1";
    postData += "&_email_field=1.email";
    postData += "&_dedupe=1";
    postData += "&_static_update=1";
    postData += "&_rp=http://ift.tt/29f7FbT";
    postData += "&_list_id=12";
    postData += "&_list_id=1";
    postData += "&_list_id=8";
    postData += "&_list_id=5";
    postData += "&_list_id=4";
    postData += "&_list_id=10";
    postData += "&_list_id=14";
    postData += "&_list_id=6";
    postData += "&_list_id=13";
    postData += "&_list_id=2035";
    postData += "&_list_id=7091";
    postData += "&_list_id=318";
    postData += "&_list_id=2";
    postData += "&_list_id=7294";
    postData += "&_list_id=317";
    postData += "&_list_id=8702";
    postData += "&_list_id=7298";
    postData += "&_list_id=7295";
    postData += "&_list_id=7297";
    postData += "&_list_id=10158";
    postData += "&_list_id=6419";
    postData += "&title=Mr";
    postData += "&first_name=fname_redacted";
    postData += "&surname=sname_redacted";
    postData += "&email=redactedg%40outlook.com";
    postData += "&company=cname_redacted";
    postData += "&position=Analyst";
    postData += "&add1=23 liverpool road";
    postData += "&add4=liverpool";
    postData += "&add5=bedfordshire";
    postData += "&postcode=l59uh";
    postData += "&telephone=1519838474";
    postData += "&sector=Accountants";
    postData += "&_employees=Less than 25";

    byte[] byteArray = Encoding.UTF8.GetBytes(postData);
    request.ContentType = "application/x-www-form-urlencoded";
    request.ContentLength = byteArray.Length;
    Stream dataStream = request.GetRequestStream();
    dataStream.Write(byteArray, 0, byteArray.Length);
    dataStream.Close();
    WebResponse response = request.GetResponse(); // 403 forbidden

    Console.WriteLine(((HttpWebResponse)response).StatusDescription);
    dataStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(dataStream);
    string responseFromServer = reader.ReadToEnd();
    Console.WriteLine(responseFromServer);
    reader.Close();
    dataStream.Close();
    response.Close();
    Console.ReadLine();

WebResponse response = request.GetResponse(); // 403 forbidden




how to get all selected checkboxes in razor

Working with a checkboxes, and stucked in transfer selected checkboxes to backend. I've an idea how to do this, but I want to hear another variants. So I've a table with checkboxes:

<td>
    <input type="checkbox" class="check" value="@item.Id"/>
</td>

And submit button

@Html.ActionLink(R("Удалить"), "DeleteSelectedPictures")

So my variant is to add bool property and change table from input to @html.checkboxfor(_ => _.selected), and how then get these selected items? Is there others way how to solve this problem?




Bind multiple values to a single checkbox and post it to controller

Model.cs

public class Test
{
  public int Id { get; set; }
  public int CreatedBy { get; set; }
  public int UpdatedBy { get; set; }
  public IEnumerable<int> ImageIdList { get; set; }
}

View.cshtml

@{
  Layout = "....";
  var assets = Model.AssetsInCampaign.ToList();
}
@using (Html.BeginForm("action-method", "controller", FormMethod.Post))
{
  <div class="btnSubmit">
    <input type="submit" value="Download Asset(s)" />
  </div>
  <div class="s_checkcol">
    <input type="submit" name="ids" />
    @foreach (var imageId in assets.Where(c => c.AssetId == doc.FileDataId).SelectMany(c => c.ImageIdList))
    {
        <input type="hidden" name="ids" value=@(imageId)>
    }
  </div>
}

Controller.cs

public ActionResult Action-Method(IEnumerable<int> ids)
{
    // code
}

NOTE: Only a part of code(where I'm facing the problem) is provided here.

I tried the above, but all of the ids are posted to the controller no matter how many checkboxes are selected.

Question: How should I bind the IEnumerable<int> ImageIdList property to a checkbox in View.cs and post the data to Controller.cs so that only the ids of selected checkboxes are posted?




asp.net fail get value from gridview checkbox

I have a GridView table which the data source is from the database. The first column of the GridView is a checkbox, the checkbox user can select checkboxes. I'm not sure where I did wrong,my code cannot get the checkbox I had ticked.

 <div id="UserFrom" class="form-horizontal" runat="server">
    <h4>Add Training</h4>
    <hr />
    <div class="alert alert-info" style="display: none;">
        <button data-dismiss="alert" class="close" type="button">×</button>
    </div>
    <div class="form-group">
        <label for="inputCode" class="col-sm-2 control-label">Training Code</label>
        <div class="col-sm-3">
            <asp:DropDownList ID="ddlRole" runat="server" CssClass="form-control" ValidationGroup="G1" required></asp:DropDownList>
        </div>
    </div>
    <div class="col-md-6">
        <asp:GridView ID="GrdRole" runat="server" CssClass="table table-striped table-bordered table-hover" EmptyDataText="No Records Found" DataKeyNames="RoleID"
            AllowPaging="true" AutoGenerateColumns="false" AutoGenerateDeleteButton="false" RowStyle-HorizontalAlign="Left" OnPageIndexChanging="GrdRole_PageIndexChanging"
            HeaderStyle-HorizontalAlign="Center" GridLines="None" PageSize="10" RowStyle-CssClass="gradeX" AlternatingRowStyle-CssClass="gradeA">
        <columns>
           <asp:TemplateField>
            <ItemTemplate>
                <asp:CheckBox ID="chkCtrl" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Name" HeaderText="Name"  />
        <asp:BoundField DataField="EmployeeNo" HeaderText="EmployeeNo"  />
        </columns>
            <PagerStyle HorizontalAlign="Right" CssClass="pagination-ys" />
        </asp:GridView>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-3 col-sm-9">
            <td>
                <asp:Button ID="submit_button" Text="Check" CssClass="btn btn-success" runat="server" OnClick="checkOuput" />
            </td>
        </div>
    </div>
</div>e

my c#

 protected void checkOuput(object sender, EventArgs e)
{
    string data = "";
    foreach (GridViewRow row in GrdRole.Rows)
    {
        if (row.RowType == DataControlRowType.DataRow)
        {
            CheckBox chkRow = (row.Cells[0].FindControl("chkCtrl") as CheckBox);
            if (chkRow.Checked)
            {
                string EmployeeNo = row.Cells[2].Text;
                data = data + EmployeeNo + " ,  " ;
            }
        }
    }
    ClientScript.RegisterStartupScript(GetType(), "alert", "alert('" + data + "');", true);
}

I'm not sure where I did wrong when I click on the check button the popup window is empty.please guide me thank you.




Angular checkboxes error

I have a little problem with checkboxes :

I have an array of objet. I do a ng-repeat on this array and i associate checkboxes on each element.

<li ng-repeat="title in treeZone track by $index">

<input type="checkbox" ng-model="title.selected" ng-click="functionAdd($index, title.selected)"/> 

</li>

My problèm is that i would like to get all the selected checkboxes with a funciton.

Do do it, i wrote that :

scope.funtionAdd = function() {

          scope.tree_array = "";

          angular.forEach(scope.treeZones, function(title) {

            if (title.selected) { 

              scope.tree_array = scope.tree_array  + title.name + " ";

            }

          });

        }

This function works well but it cause that error : "Property 'selected' does not exist on type 'Zone'" due to "title.selected"

Knowing that my Zone object have 3 properties : id, name, parent.

How resolv this issue knowing that my only way to know if a Zone is selected, is with " title.selected " .

Thanks for help :)




uncheck checkbox when i checked other checkbox

i try and not always not working, i give up. can you help for edit my code to uncheck checkbox when i checked other checkbox.i already have the code. i hope you can help for fix this problem bro

Here's my html code:

    <div class="container">
      <center>
        <h2 style="color: white; padding-top: 32px; font-size: 50px; font-family: 'Gotham Bold';"><b>Pilih Nominal</b></h2>
        <div style="margin-top: 35px; margin-left: -22px;">

          <form action="" method="POST">
            <input type="hidden" name="sqn" value="20160625110635">
            <input type="hidden" name="saldo" value="Array">
            <input type="hidden" name="mac" value="64:70:02:4a:a7:e4">
            <input type="hidden" name="tid" value="01">
            <input type="hidden" name="msidn" value="6287875230364">
            <input type="hidden" name="typ" value="PREPAID">
            <input type="hidden" name="ip" value="192.168.1.1">
            <input type="hidden" name="cmd" value="prepaid-type">
            <table id="tab1">
              <tr>
                <td id="1">
                  <button type="button" id="c1" class="unchecked">
                    1
                  </button>
                  <input type="checkbox" name="checkAll" id="checkAll" style="display: none;">
                  <input type="checkbox" name="book1" id="book" value="book1">
                  <input type="checkbox" name="book2" id="book" value="book2">
                  <input type="checkbox" name="book3" id="book" value="book3">
                  <input type="checkbox" name="book4" id="book" value="book4">
                  <input type="checkbox" name="book5" id="book" value="book5">
                </td>
              </tr>
              <tr>
                <td id="2">
                  <button type="button" id="c2" class="unchecked">
                    2
                  </button>
                  <input type="checkbox" name="checkAll" id="checkAll2" style="display: none;">
                  <input type="checkbox" name="book1" id="book" value="book1">
                  <input type="checkbox" name="book2" id="book" value="book2">
                  <input type="checkbox" name="book3" id="book" value="book3">
                  <input type="checkbox" name="book4" id="book" value="book4">
                  <input type="checkbox" name="book5" id="book" value="book5">
                </td>
              </tr>
            </table>
            <input type="submit" name="sbm" value="Submit" class="button primary">
          </form>
        </div>

Here's my js code:

    $("#1 #checkAll").change(function() {
      if ($("#1 #checkAll").is(':checked')) {
        $("#1 input[type=checkbox]").each(function() {
          $(this).prop("checked", true);
        });
      } else {
        $("#1 input[type=checkbox]").each(function() {
          $(this).prop("checked", false);
        });
      }
    });
    $("#2 #checkAll2").change(function() {
      if ($("#2 #checkAll2").is(':checked')) {
        $("#2 input[type=checkbox]").each(function() {
          $(this).prop("checked", true);
        });
      } else {
        $("#2 input[type=checkbox]").each(function() {
          $(this).prop("checked", false);
        });
      }
    });

    $('#c1').on('click', function() {
      var $$ = $(this).next('#checkAll')
      console.log($$.is(':checked'))
      if ($$.is(':checked')) {
        $(this).toggleClass('unchecked checked');
        $('#checkAll').prop('checked', false).change();
      } else {
        $(this).toggleClass('unchecked checked');
        $('#checkAll').prop('checked', true).change();
      }
    })
    $('#c2').on('click', function() {
      var $$ = $(this).next('#checkAll2')
      if ($$.is(':checked')) {
        $(this).toggleClass('unchecked checked');
        $('#checkAll2').prop('checked', false).change();
      } else {
        $(this).toggleClass('unchecked checked');
        $('#checkAll2').prop('checked', true).change();
      }
    })

Here's my fiddle: JSFIDDLE

i hope you can help bro.




mercredi 29 juin 2016

can't unchecked checkbox with input button, and what's wrong with my checkbox?

when i click the checkbox which i have integrated with javascript all under control, all checkbox which i have selected is checked to and vice versa when i unchecked.

the problem is here. 1. i will integrated button with checkbox, it's fine when i click button the checkbox is checked, but other checkbox can't follow checked.

  1. second problem when in click again for unchecked it's not working.

what's wrong with my code? it's so hard for me

Here's my html code:

<div class="container">
                <center>
                    <h2 style="color: white; padding-top: 32px; font-size: 50px; font-family: 'Gotham Bold';"><b>Pilih Nominal</b></h2>
                    <div style="margin-top: 35px; margin-left: -22px;">

                        <form action="" method="POST">
            <input type="hidden" name="sqn" value="20160625110635">
            <input type="hidden" name="saldo" value="Array">
            <input type="hidden" name="mac" value="64:70:02:4a:a7:e4">
            <input type="hidden" name="tid" value="01">
            <input type="hidden" name="msidn" value="6287875230364">
            <input type="hidden" name="typ" value="PREPAID">
            <input type="hidden" name="ip" value="192.168.1.1">
            <input type="hidden" name="cmd" value="prepaid-type">
<table id="tab1"><tr><td id="1">
    <button type="button" id="c1">
    1
    </button>
    <input type="checkbox" name="checkAll" id="checkAll">全選
    <input type="checkbox" name="book1" id="book" value="book1">book1
    <input type="checkbox" name="book2" id="book" value="book2">book2
    <input type="checkbox" name="book3" id="book" value="book3">book3
    <input type="checkbox" name="book4" id="book" value="book4">book4
    <input type="checkbox" name="book5" id="book" value="book5">book5
    </td></tr>
    <tr><td id="2">
    <button type="button" id="c2">
    2
    </button>
    <input type="checkbox" name="checkAll" id="checkAll2">全選
    <input type="checkbox" name="book1" id="book" value="book1">book1
    <input type="checkbox" name="book2" id="book" value="book2">book2
    <input type="checkbox" name="book3" id="book" value="book3">book3
    <input type="checkbox" name="book4" id="book" value="book4">book4
    <input type="checkbox" name="book5" id="book" value="book5">book5
    </td></tr>
   </table>
               <input type="submit" name="sbm" value="Submit" 
               class="button primary">
                        </form>
            </div>

Here's my javascript code:

    $("#1 #checkAll").click(function () {
        if ($("#1 #checkAll").is(':checked')) {
            $("#1 input[type=checkbox]").each(function () {
                $(this).prop("checked", true);
            });
        } else {
            $("#1 input[type=checkbox]").each(function () {
                $(this).prop("checked", false);
            });
        }
    });
      $("#2 #checkAll2").click(function () {
        if ($("#2 #checkAll2").is(':checked')) {
            $("#2 input[type=checkbox]").each(function () {
                $(this).prop("checked", true);
            });
        } else {
            $("#2 input[type=checkbox]").each(function () {
                $(this).prop("checked", false);
            });
        }
    });

 $('#c1').on('click', function(){
        var $$ = $(this)
        if( !$$.is('.checked')){
            $('#checkAll').prop('checked', true);
        } else {
            $$.removeClass('checked');
            $$.addClass('unchecked');
            $('#checkAll').prop('checked', false);
        }
    })
     $('#c2').on('click', function(){
        var $$ = $(this)
        if( !$$.is('.checked')){
            $('#checkAll2').prop('checked', true);
        } else {
            $$.removeClass('checked');
            $$.addClass('unchecked');
            $('#checkAll2').prop('checked', false);
        }
    })

This is my fiddle: JSFIDDLE




How to fire click event of checkbox in a datagrid expander header

I have a datagrid with 3 level grouping. Grouping is done in code behind using the CollectionView and PropertyGroupDescription. Every row of record will have a DataTemplateColumn (CheckBox). I would like to include a checkbox infront of each header so that I can check all the child data. Unfortunately I have tried few methods but it does not work.

xaml codes

<DataGrid.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <Expander x:Name="MyExpander" IsExpanded="True">
                                            <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                    <CheckBox Click="checkBoxHeader_Click"/>
                                                    <TextBlock x:Name="MyExpanderHeader" Text="{Binding Name}" FontWeight="Bold" VerticalAlignment="Bottom">
                                                    </TextBlock>
                                                </StackPanel>
                                            </Expander.Header>
                                            <ItemsPresenter Margin="20,0,0,0"/>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>

cs code

CollectionView collectionView = (CollectionView)CollectionViewSource.GetDefaultView(m_stationInfoList);
            PropertyGroupDescription groupDescription1 = new PropertyGroupDescription("Property1");
            PropertyGroupDescription groupDescription2 = new PropertyGroupDescription("Property2");
            PropertyGroupDescription groupDescription3 = new PropertyGroupDescription("Property3");
            collectionView.GroupDescriptions.Clear();
            collectionView.GroupDescriptions.Add(groupDescription1);
            collectionView.GroupDescriptions.Add(groupDescription2);
            collectionView.GroupDescriptions.Add(groupDescription3);




C# - How to add checkbox at specific row and column?

I want to add checkbox in a specific row and column but i'm always stumbled upon this error

"System.FormatException: Formatted value of the cell has a wrong type."

And here is my code to add the checkbox;

    private void checkboxSource(string columnSource, int n)
    {
        DataGridViewCheckBoxCell checkboxColumn = new DataGridViewCheckBoxCell();
        checkboxColumn.FalseValue = "0";
        checkboxColumn.TrueValue = "1";
        dataGridView1.Rows[n].Cells[6] = checkboxColumn;
    }

I know something is wrong when i try to bind checkboxColumn to datagridview. Can someone please guide me on how to bind the checkbox to datagridview properly provided which row and cell are taken into account. Thank you in advance.




Reverse checkbox value

I am running an angular ionic application and am having trouble reversing the value of my checkbox. I have tried the various options listed on this link (AngularJS: Reverse Checkbox State) to no avail.

I have created a directive as follows and implemented it into my checkbox as such:

<ion-checkbox negate ng-model="vm.filter.hide">
     
</ion-checkbox>


// negate.directive.js
angular
    .module('app.directory')
    .directive('negate', negate);

function negate() {
    return {
        require: 'ngModel',
        link: function(scope, element, attribute, ngModel) {
            ngModel.$isEmpty = function(value) {
                return !!value;
            };
            ngModel.$parsers.unshift(formatter)
            ngModel.$formatters.unshift(formatter);

            function formatter(value) {
                return !value;
            }          
        }
    };
}

Any insight on what might be the problem is welcome. Thanks




How to detect if checkbox changed in DataGridView?

In a winforms app, I have a cell with a checkbox. Once the user clicks this checkbox, I'd like to know. I have the following code that I've tried in the events below:

foreach (DataGridViewRow row in mygridview.Rows)
{
  if (Convert.ToBoolean(row.Cells[1].Value) {
    isChecked = true;
  }
}

I've tried the following DataGridView events with no success since Value is always null when the user is clicking the checkbox. When the user clicks a 2nd or more time, the above does capture all the previous checked checkboxes but it is too late by then. It still doesn't capture the current click.

CellClick()
CellLeave()
CellMouseUp()
CellValueChanged()
CurrentCellChanged()

Anyone have some suggestions?




All the checkboxes inside a ng-repeat are getting checked when I select just one

I have list of objects named rolePermissionList like this:

[{"id":1,"name":"createUser","type":"user","marked":1},{"id":2,"name":"deleteUser","type":"user","marked":1},{"id":3,"name":"editRole","type":"role","marked":0}]

and I use ng-repeat to repeat checkboxes using the values in that list like this

<div class="form-group">
    <label>Role Permissions:</label>
    <div class="checkbox" ng-repeat="permission in rolePermissionList">
       <label>
          <input type="checkbox" ng-model="idsPermission[permission .idPermission ]"
               ng-checked="permission.checked">
       </label>
    </div>
</div>

the ng-model of the checkboxes is named idsPermission and it's a list of numbers, those numbers are the IDS of the objects.

When I load the page the checkboxes that are supposed to be checked are checked this part works fine, but when I check another checkbox all the checkboxes gets checked, and when I uncheck a checkbox the same thing happens all the checkboxes gets unchecked.

I use that list of numbers named idsPermission to get all the IDS of the checkboxes that are checked, this worked before I used the directive ng-checked="permission.checked", but now I need to use it since now I need to show the checkboxes that are already marked.

this is my controller

angular.module('MyApp')
    .controller('RolCtrl', ['$scope', 'RolService',
        function ($scope, RolService) {
            $scope.idsPermission = {};
            $scope.getListCheckBoxesEditRole = function (idRole) {

                $scope.selectRol.descripcion;
                RolService.getListCheckBoxesEditRole(idRole)
                        .then(
                                function (d) {
                                    var userPermissionList = [];
                                    for (var permission in  d) {
                                        if (d[permission ].type === 'user') {
                                            if (d[permission ].marked === 1)
                                            {
                                                d[permission ].checked = true;
                                                userPermissionList.push(d[permission ]);
                                            } else {
                                                userPermissionList.push(d[permission ]);
                                            }
                                        }

                                    }
                                    $scope.rolePermissionList = userPermissionList;
                                },
                                function (errResponse) {
                                    console.error('ERROR');
                                }
                        );
            };
        }
        $scope.getListCheckBoxesEditRole(3);
    ]);

The RolService.getListCheckBoxesEditRole(idRole) service returns this JSON [{"id":1,"name":"createUser","type":"user","marked":1},{"id":2,"name":"deleteUser","type":"user","marked":1},{"id":3,"name":"editRole","type":"role","marked":0}]

and what I do in the controller is iterate over that list and check if the marked field is 1 if it's 1 I do this d[permission ].checked = true; I what I think that I do in that line is setting the checked value to true so I could use this directive in the html view ng-checked="permission.checked"

I tried doing this ng-checked="idsPermission[permission.checked]" but when I do this the values that are marked=1 in the JSON that I paste above don't appear checked when I load the page, but if I put it like this ng-checked="permission.checked" they appear marked as they should, but when I click a checkbox all the checkboxes gets selected.




Can Rails Simple Form checkbox label change depending on the checkbox?

I'm new to Rails and not sure if I could have 2 values for the Simple Form checkbox label and change it depending whether the checkbox gets checked. Any help with be greatly appreciated.




Disabled Checkboxes still send check=true on iOS browsers(Chrome/Safari)

I'm programatically disabling a checkbox in JQuery:

(':checkbox').attr("diabled",true);

which works fine on desktop browsers i.e. doesn't send checked=true even though the check box was checked when I disabled it (shows a grayed out check).

However, on iOS - both Chrome and Safari - disabled seems to be ignored and checked=true is still getting sent.

I've tried disabling the checkbox in HTML and it works/doesn't work in the same way.

this works fine in desktop chrome/safari - but not in iOS.

 if($('myCheckbox').is(':checked')){
   console.log("is checked");
 } else {
   console.log("is not checked or is disabled");
 }

Is there anything I'm missing here?




Reveal div based on checked radio/checkbox, multiple instances

I have to add the class 'revealed' to a div, once the radio button with the label 'yes' has been selected. So far I have my code set up so that I apply a 'required' class to the input that will be revealed, but I need to have a way to add the class 'revealed' to the 'reveal-if-active' div. This entire HTML structure will repeat as there will be multiple yes/no questions after this first one. So each 'reveal-if-active' div must be unique.

Here's the HTML structure that I am required to use:

<div class="form-group two-column">
  <input id="a1" type="radio" name="ayesno" value="1">
  <label for="a1">yes</label>
</div>
<div class="form-group two-column">
  <input id="a2" type="radio" name="ayesno" value="2">
  <label for="a2">no</label>
</div>
<div class="reveal-if-active">
  <label for="how-many-people">If <strong>yes</strong> how many people?</label>
  <input type="text" name="a-how-many-people" class="require-if-active" data-require-pair="#a1" required="">
</div>

Here's the JS I have so far:

var FormStuff = {

  init: function() {
    this.applyConditionalRequired();
    this.bindUIActions();
  },

  bindUIActions: function() {
    $("input[type='radio'], input[type='checkbox']").on("change", this.applyConditionalRequired);
  },

  applyConditionalRequired: function() {

    $(".require-if-active").each(function() {
      var el = $(this);
      if ($(el.data("require-pair")).is(":checked")) {
        el.prop("required", true);
        $('[data-id=' + $('input:checked').prop('id') + ']').addClass('reveal'); 

      } else {
        el.prop("required", false);
        el.removeClass("revealed");
      }
    });

  }

};

FormStuff.init();




Jquery not able to find checkbox ID or Name

I've got a page of checkbox that are styled. I'm trying to return their name or ID when they are changed.

I've created a fiddle here: http://ift.tt/29peJ1O

That shows the issue. The jquery I'm using is :

$(document).ready(function() {
    $(this).change(function() {
        alert($(this).attr("name"));
        alert($(this).attr("id"));
    });
});

Can anyone advise why this isn't working ?

Thanks




mycheckbox.setSelected(false) has no effect

I have columns of checkboxes, the top row of which are CheckAll checkboxes for that particular column. If I uncheck the Checkall from the first CheckAll checkbox in the leftmost column I would like to uncheck the remaining CheckAll checkboxes.

However the mycheckbox.setSelected(false) has no effect. If however, I do a mycheckbox.setEnabled(false) (just as a test) it DOES work and the checkbox is disabled.

By the way, this is a "header row" for a listview with a custom adapter. The contents of the listview work as expected.

Any idea how to get the checkbox unchecked?




How to display different checkbox name based on current time?

I'm building an app to remind people to take medication, the app will display the medication(s) the user should take based on the current time, e.g if the user need to take medication 1 and 2 at 10am, then when the time is 10am-10:59am, the checkboxes will display "medication 1" and "medication 2" for the user to tick off. But if the user need to take medication 3 and 4 at 9pm, then at 9pm-9:59pm, the checkboxes will display "medication 3" and "medication 4".

The html I currently have:

               <div id=aa style="display:none">
        <form>
            <input type="checkbox" name="Medication 1" value="one">Supplement One<br>
            <input type="checkbox" name="Medication 2" value="two">Supplement Two<br>
            <input id=xbutton type="button" onClick="validate()" value="Submit">
        </form>

    </div>

Right now as you can see the app will display just Medication 1 and Medication 2 no matter what time the user open the app. Is there a way to make the checkboxes display different words based on the current time?




When i ckeck a checkbox all checkboxes are checked (Swift)

Hello i have a collection view in which i have a checkbox in every cell. I use this checkbox http://ift.tt/29bZyge.

All cells have their checkbox but the problem as the title says is that when i tap on the checkbox all checkboxes are checked. Actually when i tap the first all odds checkboxes (1-3-5-7-...) are checked and when i tap the second then all checkboxes are checked.

I connected the view to my cell file i change it to WOWCheckbox as the documentation says.

I didn't change anything else.

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Interest Cell", forIndexPath: indexPath) as! ThirdTabCell


        cell.check1.tag = indexPath.row
        cell.check1.addTarget(self, action: #selector(ThirdTab.follow(_:)), forControlEvents: UIControlEvents.TouchUpInside)

        return cell



    }




func follow(sender:WOWCheckbox!) {
        print("check")
    }

When i use this code when i tap a checkbox it prints check only once. I believe i somehow i have to declare which check i tap but i don't know how to use it.




Contact form 7 - how can i catch and customize each checkbox?

how can i catch and customize each checkbox in Contact form 7 plugin?

i have a list of checkboxes in a single field.

what i'm trying to do is to add an attribute and value using jQuery to each checkbox.

like this:

$("input['type=checkbox']:nth-child(3)").attr("data-price", 500).addClass("cf7-checkbox");

thanks so much!!!




Making checkbox transparent [duplicate]

This question already has an answer here:

I've made a form with a checkbox. Now I need to make a checkbox appear as on the image:

checkbox transparent

What would be the best way to achieve this?

Also, they checkbox should be :checked once the label is clicked.

HTML:

<label>
    <input id="custom-checkbox" type="checkbox" required>
    Disclaimer: Click here if you are okay...
</label>




.checked is undefined when using a custom checkbox

I found this in the internet: enter image description here

and this is the code:

style.css

input[type="checkbox"] {margin-right: 5px;}
.header {margin-bottom: 30px;}
.chooseLib{border-bottom: 1px solid #000; padding-bottom: 10px; margin-bottom: 20px;}
.libs {list-style-type: none; margin: 0px; padding: 0px;}
.libs li {background: #d7e3f0; padding: 10px;  margin-bottom: 3px; cursor: pointer;}
.libs li.marked {background: #b4dfa6;}
.libs li span.glyphicon{margin-right: 10px; float: right;}
.alert{margin-top: 20px;}

checkbox.html

            <ul class="libs">
                <li ng-repeat="participant in participantsList" ng-class="{marked: participant.checked}" ng-click="participantChanged(participant.checked)"  ng-switch on ="participant.checked"><span> </span> <span class="glyphicon glyphicon-ok" ng-switch-when="true"></span></li>
            </ul>

the problem is that "participant.checked" is undefined which means that all my checkbox stay in gray (the picture is what I want to realize)




Simple JS function in order to set a list of checked boxes in a form does not work

so i'm i'm using basic JS and PHP to write a form. In a that form i have several checkboxes in which the user can click to add it to his object.

<div class="input-group input-group-sm">
     <span class="input-group-addon">Tube(s) : </span>
     <input id="tube" name="tube" type="text" class="form-control" placeholder="ex :TH2132A" style="display:none" required>
</div>
<div style="max-height:150px;overflow:auto;margin:5px;border: 1px solid;">
     <table class="table table-striped" >
       '.$this->tabTubeModif().'
     </table>
</div>

As u see i'm calling a function in order to build the table that contains all my checkboxes. This function checks the related object attributes in order to render the correct information in the form.

public function tabTubeModif($outil){
    $tubes=type::findAll();
    $res='';
    foreach ($tubes as $tube){
        if (in_array(str_replace(" ","-",$tube->__get("nom")),explode("/",$outil->__get("liste_tubes")))){
            $res .= '<tr><td>' . str_replace(" ", "-", $tube->__get("nom")) . '</td><td><input type="checkbox" id="' . str_replace(" ", "-", $tube->__get("nom")) . '" onchange=editListTube("' . str_replace(" ", "-", $tube->__get("nom")) . '") value="'. str_replace(" ", "-", $tube->__get("nom")) . '" checked="checked" </td></tr>';
        }
        else{
            $res .= '<tr><td>' . str_replace(" ", "-", $tube->__get("nom")) . '</td><td><input type="checkbox" id="' . str_replace(" ", "-", $tube->__get("nom")) . '" onchange=editListTube("' . str_replace(" ", "-", $tube->__get("nom")) . '") value="' . str_replace(" ", "-", $tube->__get("nom")) . '" </td></tr>';
        }
    }
    return $res;
}

And onchange of the checkbox i'm calling a js function :

function editListTube(id_check){
alert(document.getElementById("tube").value)

var vale="#"+id_check;


if (document.getElementById(id_check).checked){
    alert(vale+'CHECK2');
    if ( document.getElementById("tube").value==''){
        document.getElementById("tube").value+=id_check;
    }
    else{
        document.getElementById("tube").value+='/'+id_check;
    }
}

else{
    alert(document.getElementById("tube").value)
    alert(vale+'UNCHECK2');

    var val='';
    var vals = document.getElementById("tube").value.split('/');

    for (var i=0; i<vals.length;i++){
        if (vals[i]==document.getElementById(id_check).value){
            vals.splice(i, 1);
        }
    }
    for (var j=0; j<vals.length;j++) {
        if (j==vals.length-1){
            val+=vals[j];
        }
        else{
            val+=vals[j]+'/'
        }
    }
    document.getElementById("tube").value=val;
}

}

Basically it is just suppose to add/remove the corresponding string from the hidden text input "tube". But i have 2 problems.

First as you see i set up some alerts in my js function to see in which part of the code i am, and it seems that when the checkbox is checked when the form loads, weather i check or uncheck i always pass by the "uncheck" part of the code...I believe this is due to (in TabTubeModif) the way i check them "checked="checked"" but i can't think of another way to do it.

2nd problem comes on alert(document.getElementById("tube").value) returns empty, when on the page and in the genrated html code it definitely has a value :enter image description here

So just to sum up my problem : If a box is checked on the load of form, i uncheck it once, i pass by the good part of my code but the "#tube" field is not updated cause it's value seems empty (when its not in fact). And if i try try to re-check that same box, it goes in the uncheck part of the js code...

Any help appreciated !




how to fire ng-change event through spacebar key for a input type checkbox which is present in li element

<li ng-repeat="currentValue in model.bindedValueTemp | value: model.valueSearchText | orderBy: 'Value'"  tabindex="5">
        <label>
            <input type="checkbox" ng-model="model.ValueModel[model.selectedValue.Key][currentVal.Value]"  ng-change="Result(model.selectedValue.Key, currentValue.Value)" />
            <span></span>
        </label>
        <span class="item"></span>
</li>




mardi 28 juin 2016

Checkbox implementation in Angular2 using Material

I'm trying to implement a checkbox in Angular2 using Material. I've referred to http://ift.tt/294qiyi which contains everything about using checkboxes in Angular2 using Material. But, its too complex and time consuming to study and use that.

If any of you have implemented it, please help me.I want the checkbox to look like this.




How to show a unique image for each checkbox item?

my MVC application has a few checkbox items, however, I need to show unique images for each checkbox item, each item is unique so a unique image should too.

Here's what I tried:

View(Index.cshtml):

//MULTIPLE CHECK BOX
for (int i = 0; i < Model.CheckBoxItems.Count; i++) //this line throws an exception (null)
{
    <img src="@Url.Content(Model.CheckBoxItems[i].ImageUrl)" />
    <div>

        @Html.HiddenFor(m => m.CheckBoxItems[i].CBName)
        @Html.LabelFor(l => l.CheckBoxItems[i].CBIsSelected, Model.CheckBoxItems[i].CBName)

        @Html.CheckBoxFor(r => r.CheckBoxItems[i].CBIsSelected, false);
    </div>
}

Controller(HomeController.cs):

 [HttpGet]
    public ActionResult Index()
    {
        ModelVariables model = new ModelVariables()
        {       
            CheckBoxItems = Repository.CBFetchItems()        
        };
        return View(model);
    }

Model(ModelVariables.cs):

  public class ModelVariables
{
    //CHECKBOX
    public List<Item> CheckBoxItems { get; set; } 
}


public class Item
{
    public string CBName { get; set; }
    public bool CBIsSelected { get; set; }
    public string ImageUrl { get; set; }
}

public static class Repository
{   
    public static List<Item> CBFetchItems()
    {
        return new List<Item>()
        {
            new Item(){  CBName = "Girls?" },
            new Item(){  CBName = "Dudes?" },
            new Item(){  CBName = "Animals?" },
            new Item() { ImageUrl  = "~/Assets/ass.PNG"}
        };
    }     
}

When you copy/paste this code and run it, you will get a null exception error.




Changing states of checkbox with even trigger

I have this CheckBox:

<CheckBox x:Name="checkNotAppointed" Grid.Column="1" Grid.Row="2" Content="Not Appointed" >
    <CheckBox.Style>
        <Style TargetType="{x:Type CheckBox}">
            <Setter Property="Margin" Value="2" />
            <Setter Property="IsEnabled" Value="True" />
            <Setter Property="IsChecked" Value="{Binding FilterForNotAppointed, UpdateSourceTrigger=PropertyChanged}" />
            <Style.Triggers>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsChecked, ElementName=checkElder}" Value="True" />
                        <Condition Binding="{Binding IsChecked, ElementName=checkMinisterialServant}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="True" />
                </MultiDataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsChecked, ElementName=checkElder}" Value="False" />
                        <Condition Binding="{Binding IsChecked, ElementName=checkMinisterialServant}" Value="True" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsEnabled" Value="True" />
                </MultiDataTrigger>
                <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                        <Condition Binding="{Binding IsChecked, ElementName=checkElder}" Value="False" />
                        <Condition Binding="{Binding IsChecked, ElementName=checkMinisterialServant}" Value="False" />
                    </MultiDataTrigger.Conditions>
                    <Setter Property="IsChecked" Value="True" />
                    <Setter Property="IsEnabled" Value="False" />
                </MultiDataTrigger>
            </Style.Triggers>
        </Style>
    </CheckBox.Style>
</CheckBox>

If I untick either checkElder or checkMinisterialServant it has no affect on checkNotAppointed. Correct.

If I then untick both of them, it checks the checkNotAppointed and disables. Correct.

If I then check one of the other two, it enables checkNotAppointed but always unchecks it. Why?




Making CheckBox Appear Enabled

How would I go about making a disabled checkbox appear as though it is enabled. I have tried setting the opacity, foreground, background, and masks, but to no avail:

<Style x:Key="CheckBoxDisplay" TargetType="CheckBox">
    <Style.Triggers>
        <Trigger Property="IsEnabled" Value="False">
            <Setter Property="Opacity" Value="1"></Setter>
            <Setter Property="Foreground" Value="Blue"></Setter>
            <Setter Property="Background" Value="Blue"></Setter>
        </Trigger>
    </Style.Triggers>
</Style>

I could easily just give the checkboxes an event to disallow people to change it's state by just changing it back, but that seems like cheating.




Checkbox content IE 11/Edge

I face a problem with checkbox in IE and Edge, namely a "content" class. I have the following code:

HTML

<input id="checkbox" type="checkbox" class="checkbox-edit-article" name="breakingNews" ng-model="showPublished" ng-change="updateCategory(selectedCategory, pageID)">
        <label for="checkbox" class="checkbox-edit-article-label">Show only published articles</label>
    </input>

When field is checked

.checkbox-edit-article:checked + .checkbox-edit-article-label:before {
content: url(../img/mark-white.png);
background: rgb(49,119,61);
color: #fff;
height: 44px;
line-height: 2.4;
transition: all .2s;

and static

.checkbox-edit-article + .checkbox-edit-article-label:before {
content: '';
background: #fff;
border: 1px solid #BFBFBF;
display: inline-block;
vertical-align: middle;
width: 43px;
height: 44px;
margin-right: 10px;
margin-top: 1px;
text-align: center;
box-shadow: inset 0px 0px 0px 1px white;

in Chrome "content: url(../img/mark-white.png);" is displayed perfectly, but in IE this check image is too high because of "line-height", but I don't know how to center the picture in the checkbox.

I ask your help, how i can align the image?

Thank you in advance!




is there a way to find a specific checkbox and check it using Selenium-Webdriver?

I am having trouble making my Selenium-Webdriver script check Susie's checkbox. I have tried using clicking and sending space keys, and also changing my xpaths. Could someone please help me find a way of specifying that I need Susie's checkbox, and also help me click it?

<tr class="dataRow">
    <td class="jtable-selecting-column">
         <input type="checkbox">
    </td>
    <td class=" FirstName ">Laura</td>
    <td class=" LastName ">Test</td>
    <td class=" SMSNumber ">4444444444</td>
    </tr>
<tr class="dataRow">
    <td class="jtable-selecting-column">
         <input type="checkbox">
    </td>
    <td class=" FirstName ">Susie</td>
    <td class=" LastName ">Test</td>
    <td class=" SMSNumber ">5555555555</td>




angular checkbox does not bind to model

In my controller I have this member:

$scope.sameOptionsOnReturn = true;

and in my view:

<input type="checkbox"
       ng-model="sameOptionsOnReturn"
       ng-checked="sameOptionsOnReturn"
       ng-value="true"
       ng-change="setReturnOptions" />

But the input does not bind to the checkbox; it's always true. What is wrong?




Javascript confirm box-checkbox

Im interested in how to make a confirm box in Javascript that would be triggered by onchange method on several cboxes. So i need 2 checkboxes for like ON and OFF values. If someone checks or unchecks one, confirm box will show and if clicked OK, then the state of cbox will change, if not then the value will not be changed. Any ideas?

Thank you.




ng-checked not updating first time

I'm generating check boxes using ng-repeat, and their initial status can be checked or unchecked depending on if that information exists or not in the data. My problem is that altghough it shows their initial checked/unchecked status correctly, when I uncheck a box that has been 'pre-checked', the box physically unchecks but the model doesn't change. Then I check it again, and the model doesn't change but it's correct. Then I uncheck again, and it clears correctly in the model and works correctly from then on. I have been working on this problem for days and I'm totally stuck! Can anyone see if I'm doing something stupid? My feeling is that it's an initialisation problem but I'm too close to it to see now. Thanks!

<!-- if this is a checkbox to be drawn -->
<div ng-if="option.option_type=='checkbox'">
  <label class="item-checkbox-right">
   
   <!-- handle multiple options -->

  <!-- if answered_options[n]weight exists, make option.ans = weight --></label>
  <ul ng-repeat="opti in questionpart.survey_answer[0].answered_options">
    <li style="list-style: none; display: inline">

    <!-- if option is set in the received data, set it in the model -->
      <div ng-if="opti.id == option.id">
        <div ng-init="option.ans = option.weight"></div>
      </div>
    </li>
  </ul>
  <label class="item-checkbox-right">
      <!-- show the checkbox and bind to option.ans-->
      <input class="checkbox-light" 
      type="checkbox" 
      name="" 
      ng-false-value="0" 
      ng-true-value=""
      ng-model="option.ans"
      ng-checked="option.ans==option.weight" />
  </label>
</div>




Custom checkbox is not aligned with text

Im im trying to create custom checkboxes in GWT using only CSS So far i was able to style checkboxes that DO NOT have text near them. However checkboxes with text are looking messy

Current state: Messy style

Desired behaviour: Right behaviour

  <span class="gwt-CheckBox" id="i294">
<input tabindex="0" id="gwt-uid-3" type="checkbox" value="on">
<label for="gwt-uid-3">Run task immediately after finish</label>
</span>

HTML

input[type="checkbox"] {
    visibility: hidden;

}
input[type="checkbox"]+label {
    display: inline-block;
    width: 16px;
    height: 16px;
    background: url(images/custom_html_elements_sprite.png) 0 0;
}

input[type="checkbox"]:checked+label {
    display: inline-block;
    width: 16px;
    height: 16px;

    background: url(images/custom_html_elements_sprite.png) -64px 0;
}

CSS

Any help would be appreciated

EDIT:

fiddle provided

http://ift.tt/290KMVX




Angular filter with multiple checkboxes in separate filters

I do something wrong because I can't achieve the result that I need.

My JSON data looks like this

[{
type_id: 1, 
brand_id: 0,
name: 'Title',
description: 'Description',
img: 'url'
},...]

So I need to filter data by type_id and brand_id It has not to be a complicated task but stuck a lot and I will appreciate for any help from you I just can't handle it for now.

And this is how my view looks like. I have two filters that generated by ng-repeat and ng-repeat for devices I need to filter by type and brand filter.

// filter 1
<div class="filters">
   <h3 class="filters__title">Choose by type</h3>
   <div class="swiper-container">
      <div class="swiper-arrow-prev"></div>
      <div class="swiper-arrow-next"></div>
      <div class="swiper-overflow">
         <div class="swiper-wrapper filter" data-id="type">
            <div class="swiper-slide filter__checkbox" ng-repeat="item in types">
               <input type="checkbox" name="" id="filter-" ng-model="item.id" ng-checked="item.id">
               <label for="filter-">
               <span></span>
               </label>
            </div>
            <!-- /item -->
         </div>
         <!-- /filter -->
      </div>
   </div>
</div>
<!-- /filters -->

// filter 2
<div class="filters">
   <h3 class="filters__title">Choose by brand</h3>
   <div class="swiper-container">
      <div class="swiper-arrow-prev"></div>
      <div class="swiper-arrow-next"></div>
      <div class="swiper-overflow">
         <div class="swiper-wrapper filter" data-id="brands">
            <div class="swiper-slide filter__checkbox" ng-repeat="brand in brands">
               <input type="checkbox" name="" id="brand-" ng-model="brand.id">
               <label for="brand-">
               <img ng-src="" alt="">
               <span></span>
               </label>
            </div>
            <!-- /item -->
         </div>
         <!-- /filter -->
      </div>
      <!-- /swiper-overflow -->
   </div>
   <!-- /swiper-container -->
</div>
<!-- /filters -->


<div class="card" ng-repeat="device in devices">
   <div class="card__wrap">
      <figure>
         <img ng-src="" alt="">
      </figure>
      <!-- /img -->
      <h3 class="card__title"></h3>
   </div>
</div>
<!-- /card -->


angular.module('app', []).controller('mainCtrl', ['$scope', 'dataJSON', '_', function($scope, dataJSON, _) {
            $scope.filterContainer = [];

            // get Data
            dataJSON.getPromise().then(function(data) {
                $scope.brands = data.brands;
                $scope.devices = data.devices;
                $scope.types = data.device_types;

                return data.devices;
            }).then(function(data) {

            })
        }])




android: how to get the gridview position while its checkbox item is checked?

I have a custom gridview with checkbox, imageview and textview. In the gridviewAdapter.getView(), i have used rows and holder to initialise the values for checkbox, imageview and textview. Now when I click on checkbox, I need to fetch the position of that gridview item so i can move the image from its position to another position in a gridview.

public View getView(int position, View convertView, ViewGroup parent) {
    View row = convertView;
    ViewHolder holder = null;
    if (row == null) {
        LayoutInflater inflater = ((Activity) context).getLayoutInflater();
        row = inflater.inflate(layoutResourceId, parent, false);
        holder = new ViewHolder();
        holder.imageTitle = (TextView) row.findViewById(R.id.textView);
        holder.image = (ImageView) row.findViewById(R.id.imageView);
        holder.cb=(CheckBox)row.findViewById(R.id.checkBox);

            holder.cb.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    //here with this checkbox which just got clicked,
                    // i want to access its gridview position or holder index
                    // so i can get access to the image

                }
            });
        row.setTag(holder);
    } else {
        holder = (ViewHolder) row.getTag();
    }

    ImageItem item = (ImageItem)dataArraylist.get(position);
    holder.imageTitle.setText(item.getTitle());
    holder.image.setImageBitmap(item.getImage());
   // holder.cb.setChecked(item.isSelected());

    return row;
}
    public static class ViewHolder {
    public TextView imageTitle;
    public ImageView image;
    public CheckBox cb;
}




How to retrieve data from MySQL array and make checkbox checked in list

I have a form in which I display numbers of company with checkbox. User checked these company and save this in a database table. Now I want to make an update form where I want that when data retrieve from database the checkbox is already checked in list which is checked by user while entering data.




lundi 27 juin 2016

Get item values from checked items with AngularJS

I currently have a webpage set up that shows a tile with some info on it. I want this tile to remain unchanged. There are any number of tiles in a column, and I've formatted it so that a checkbox sits next to each tile. I want to write some Angular code that gets the info for each tile when a button is clicked, however the way it is written now does not bind the data to the checkbox. Is there a way to get this data? I've tried a foreach statement but it only gets html info for the checkboxes rather than the tiles.

<div ng-repeat="item in group.items">                 
     <span>
          <input type="checkbox" class="checkbox-item" ng-model="item.checked" ng-click="updateBulkSelectedCount(item)"/>
     </span>

     <div>
          <a href="" ng-click="vm.go(item)" ui-sref="foo.bar({Id: item.Id, docNumber: item.Identifier})">
          <div class="tile"></div>
     </div>
</div>




use Dojo to programaticlly set checkboxes checked

The codes below returns Uncaught TypeError: Cannot set property 'checked' of null. what is the correct way to programmatic set checkbox as checked?

        array.forEach(this._getAllCheckBoxIDs(), function(item){
            dom.byId(item).checked = true;
        }, this);




Android Custom Listview Checkbox Scroll

Hi everyone I work android custom listview with checkbox example. But I did this example. Clicking the List row, the checkbox selected. But my listview scrolls bottom-top, selected checkbox change. Please help me. Thanks everyone. My code

public class YoklamaListAdapter extends BaseAdapter {

private Activity activity;
private LayoutInflater inflater;
public List<MovieYoklama> yoklamaItems;
boolean selected = false;
private RequestQueue mRequestQueue;
private int selectedPosition = -1;
private int selectedStart = 0;

public YoklamaListAdapter(Activity activity, List<MovieYoklama> movieItems) {
    this.activity = activity;
    this.yoklamaItems = movieItems;
}

public RequestQueue getRequestQueue() {
    if (mRequestQueue == null) {
        mRequestQueue = Volley.newRequestQueue(activity);
    }

    return mRequestQueue;
}

@Override
public int getCount() {
    return yoklamaItems.size();
}

@Override
public Object getItem(int location) {
    return yoklamaItems.get(location);
}

@Override
public long getItemId(int position) {
    return position;
}

public boolean isSelected() {
    return selected;
}

public void setSelected(boolean selected) {
    this.selected = selected;
}

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

    if (inflater == null)
        inflater = (LayoutInflater) activity
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null)
        convertView = inflater.inflate(R.layout.listturyoklama_row, null);

    ImageView thumbNail = (ImageView) convertView
            .findViewById(R.id.thumbnailYoklama);
    TextView title = (TextView) convertView
            .findViewById(R.id.txtYoklamaTitle);
    TextView kisiID = (TextView) convertView
            .findViewById(R.id.txtYoklamaKID);
    TextView kisiTip = (TextView) convertView
            .findViewById(R.id.txtYoklamaKTip);
    CheckBox chk = (CheckBox) convertView.findViewById(R.id.chckYoklama);

    MovieYoklama m = yoklamaItems.get(position);
    if (selectedStart == 0) {
        chk.setChecked(true);
        m.setCheckbox(true);
    } else {
        if (position == selectedPosition) {
            if (!m.isCheckbox()) {
                chk.setChecked(true);
                m.setCheckbox(true);
            } else {
                chk.setChecked(false);
                m.setCheckbox(false);
            }
        }
    }
    thumbNail.setImageResource(m.getThumbnailUrl());

    // title
    title.setText(m.getTitle());
    // ID
    kisiID.setText(m.getID());
    // Tip
    kisiTip.setText(m.getTip());
    return convertView;
}

public void setCheckBox(int position) {
    selectedPosition = position;
    selectedStart = 1;
    notifyDataSetChanged();
}

}

My MovieYoklama Class

public class MovieYoklama {

private String title, ID, Tip;
int thumbnailUrl;
private boolean checkbox;

public MovieYoklama() {
}

public MovieYoklama(String name, int thumbnailUrl, boolean checkbox,
        String ID, String Tip) {
    this.title = name;
    this.thumbnailUrl = thumbnailUrl;
    this.checkbox = checkbox;
    this.ID = ID;
    this.Tip = Tip;
}

public String getTitle() {
    return title;
}

public void setTitle(String name) {
    this.title = name;
}

public String getID() {
    return ID;
}

public void setID(String ID) {
    this.ID = ID;
}

public String getTip() {
    return Tip;
}

public void setTip(String Tip) {
    this.Tip = Tip;
}

public int getThumbnailUrl() {
    return thumbnailUrl;
}

public void setThumbnailUrl(int thumbnailUrl) {
    this.thumbnailUrl = thumbnailUrl;
}

public boolean isCheckbox() {
    return checkbox;
}

public void setCheckbox(boolean checkbox) {
    this.checkbox = checkbox;
}

}

And Then listview click by Activity clases

private YoklamaListAdapter adapteryoklama;
----------
listViewYoklama.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            adapteryoklama.setCheckBox(position);

        }
    });




checkboxGroupInput with accents

I'm trying to use checkboxGroupInput in my shiny app with accents like this:

column(3,
  checkboxGroupInput("plotType", "Selecciona el estilo de la gráfica",
                     c("Líneas"="line", "Puntos"= "point"), "line")
                     )

But when I run the app the title of the checkbox is fine (where accents are present) but in the options it prints out:

Selecciona el estilo de la gráfica:

[ ] L < U + 0 0 E D > neas

[ ] Puntos

What can I do to print the accents in "Líneas" correctly???




How to use unbound checkbox in a Continuous Subform - MS Access 2013

I'm fairly new to Access and having a really hard time figuring out each and every bit of it. Now I want to have a grid containing rows fetched from a query and a checkbox for every row. Here's what I want:

  1. User should be able to select individual checkbox to select the row.
  2. A "Select all" checkbox to select all rows.
  3. Only upon clicking a button the rows must be updated

I have

  1. Created a form.
  2. Added a Continuous Subform and the Rowsource has a checkbox bound to a Yes/No field.

I'm stuck at this point. Please refer to the attached image and help me figure this out. Please suggest some good tutorials with practical examples. Thanks a lot.enter image description here




Unable to fire javascript event OnClick of checkbox

So I have a checkbox control that I cannot get to fire OnClick. I've tried a number of different ways: Binding the event onload; adding the event as a parameter in the tag

Here is my most recent iteration of code. I'm trying to fire an "Alert" just to confirm that it changed.

<section class="border-bottom">
         <div id="approx" class="content">
          <h3>This is my approximate location</h3>
          <div class="form-control-group">
           <div class="form-control form-control-toggle" data-on-label="yes" data-off-label="no">
               <input type="checkbox"  />
           </div>
          </div>

         </div>
    </section>

$('input[type="checkbox"]').bind('click', function(){
    alert("OK");
    })

I also wouldn't mind being able to run it via the input

<input type="checkbox" onclick="runMyFunction(); return false;" />




In CSS how do I style checkbox or radio button for pressed state apart from checked and not checked?

I am using invisible radio buttons and checkboxes with visible labels to create mode UI (single mode active at any time) and toggle buttons respectively. Ideally I want to have a different image for each of the following states

  1. Unchecked
  2. Pressed
  3. Checked

I have used the following template. The :checked and :not(:checked) selectors are working. For buttons elements, :active seems to work for mouse down/pressed state. For checkboxes and radiobuttons, they don't seem to work. How do I do a style for just mouse down/pressed state?

    input#toggle_button:not(:checked) ~label{
      content: url(../assets/button_toggle_normal.png);
    }

    input#toggle_button:checked ~label{
      content: url(../assets/button_toggle_selected.png);
    }

    input#toggle_button:active ~label{
      content: url(../assets/button_toggle_pressed.png);
    }




Checkbox in note editor - UWP

I just wondering if there is a way to place Checkboxes beside a text line in a edit panel like richtextbox. What I mean is something like Onenote app and a simple to-do list:

enter image description here

Is it possible to do this with build-in UWP element or ...?




sort checked checkbox on datatables

I have a table using datatables. It contains a checkbox on first column. How can I sort the table so when a checkbox is checked, the checked row should go on top?

<table class="table table-bordered table-striped">
  <thead align='center'><tr><th></th><th>Alphabet</th><th>Numeric</th></tr></thead>
  <tbody align='center'>
    <tr>
      <td><input type='checkbox' name='id[]' value=1></td>
      <td>A</td>
      <td>10</td>
    </tr>
    <tr>
      <td><input type='checkbox' name='id[]' value=2></td>
      <td>B</td>
      <td>100</td>
    </tr>
    <tr>
      <td><input type='checkbox' name='id[]' value=3></td>
      <td>C</td>
      <td>1000</td>
    </tr>
  </tbody>
</table>




Rails and Checkbox: Only allow one checkbox to be checked [duplicate]

This question already has an answer here:

I have a form in my rails app with checkboxes that I actually want to behave like a select with a list. I want my user to be only able to select one checkbox at a time (so if he clicks the other checkbox the originally selected checkbox is automatically unchecked). Here's my code :

<%= f.fields_for  :answer do |a| %>
    <%= a.label "Answer Type :" %>
    <br>
    <% Answer.answer_type.options.each do |option| %>
      <%= a.label option.first %>
      <%= a.check_box(:answer_type, { multiple: false}, option.first, nil) %>
      <br>
    <% end -%>
<% end -%>

Is there a nice rails way to achieve that ?




Using IF & AND statements with Checkboxes on a Userform

A little background: I have so far created a userform with checkboxes that each run separate macros initially then when unchecked they run an identical macro to return to the "normal" state. This was done using an IF, Else statement.

My question is how to combine the If statement with an AND statement so when/if two boxes are checked they run a different code or macro.

I am still very new to VBA and coding but it seems like a rather simple idea to me as I got the IF else statement to work. But for some reason the code I have been trying hasn't been working and I dont recieve any errors it just doesn't do anything when I have both boxes checked.

The code I have been trying is:

Private Sub cbXray_Click()

If cbXray.Value = True And cbSCH40.Value = True Then
 ActiveCell.FormulaR1C1 = _
        "=((RC[-6]*'Sched 40 Table Data'!R[1]C[1])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select

Else

Range("P7").Select
ActiveCell.FormulaR1C1 = _
    "=((RC[-6]*'Sched 40 Table Data'!R[1]C[-11])+(RC[-5]*'Sched 40 Table Data'!R[1]C[-10])+(RC[-4]*'Sched 40 Table Data'!R[1]C[-9])+(RC[-3]*'Sched 40 Table Data'!R[1]C[-8])+(RC[-2]*'Sched 40 Table Data'!R[1]C[-7])+(RC[-1]*'Sched 40 Table Data'!R[1]C[-6]))"
Range("P7").Select
Selection.AutoFill Destination:=Range("P7:P30"), Type:=xlFillDefault
Range("P7:P30").Select
End If


End Sub

Thank you in advance!