lundi 31 décembre 2018

Why HTML (DOM) is generating for my Multi Choice Options control in Nintex

I am using Nintex Development 1.11.3.0 with SharePoint 2010 and I am running into kind of unusual Issue.

When I create any Multi-choice option in my form, the HTML script shows me "on" as a value for all the options. i.e. <input value="on"/> as you can see HTML for my choice control and what I am expecting is What other people have. Does anybody know how I can fix this?

Thank you in advance.




How can i use ElementRef instead of document.getElementById to fetch the nodeList

Currently I am using document.getElementById to fetch the exact checkbox that needs to be checked.

here is the code:

setTimeout(function () {
                    this.tradeids = JSON.parse(sessionStorage.getItem('tradeids'));

                    var x;


                    for (let objtrade of this.tradeids) {
                         x = document.getElementById(objtrade);
                        x.checked = true;
                    }

                    this.programIds = JSON.parse(sessionStorage.getItem('programIds'));
                    var y;
                    for (let objprogram of this.programIds) {
                        x = document.getElementById(objprogram);
                        x.checked = true;
                    }
                }, 100);
            }

how can i replace document.getElementbyId with elementRef or any other typescript function.

FYI, I did use elementRef using querySelector but the log says that nativeElement is undefined.




Working with Checkboxes in Loadrunner (Web HTTP/HTML)?

I am trying to record a simple Web Application which as activity of checking checkboxes as below and clicking on Submit button:

enter image description here

After recording the script is generated a post request as below:

web_submit_data("NonInvObjectSubmit", 
    "Action=URL", 
    "Method=POST", 
    "RecContentType=text/html", 
    "Referer=URL", 
    "Snapshot=t23.inf", 
    "Mode=HTML", 
    ITEMDATA, 
    "Name=PageStart", "Value=1", ENDITEM, 
    "Name=[4].bCheckBox", "Value=true", ENDITEM, 
    "Name=[4].Id", "Value=11701", ENDITEM, 
    "Name=[4].bCheckBox", "Value=false", ENDITEM, 
    LAST);

Observed the Value = 11701 is incrementing for each time the checkbox is used.
Replaying the same with different Index number, doesn't actually checks the checkbox.(tried providing empty Value, Random Value but nothing worked.)

Please Help. Thank you




HOW TO USE ONE JCHECKBOX ONLY

I been searching all the websites and also in youtube to find out how to use to use one jcheckbox in my project.

I want to function this checkbox as enable and disable, also i want to use to inter single data into database table

kindly support.....




Place checkbox inline with paragraph text

How can i put that checkbox inline with the text?

The html code is:

<div class="checkbox checkbox_allow_div"><label class="label_300"><input type="checkbox" name="allow" value="1" class="allow_checkbox"><?php echo gdpr_text('gdpr_order_text'); ?></label></div>

The text, that i echo with php, its comeing from sql table, and its writed in a ckeditor on the admin page. Ckeditor put the text automatically in <p> tags.

I cant put the checkbox code into that texts html code, bacause the user is writing the text on the admin page, so its always dynamic.

enter image description here




dimanche 30 décembre 2018

How to count number of checkboxes on open object in view?

I am trying to count the number of checkbox elements on the current panel I am on. What is happening is that I have checkboxes on 4 panels, on each panel there are checkboxes. Only one panel can be open at a time. When I do a count of checkboxes, I am getting the total of all the checkboxes in my app and not the number on the panel I am showing.

I have tried specifically telling the code that this is the window open var a = angular.element(document.querySelector('[widget-id="popup-1"] div')).scope().$parent.me.visible
but to no avail,

I am not sure how to tell the code that this is the panel that is open, count checkboxes on it only.

I am trying to count the number of boxes, then compare checked boxes and if num = checked, then I will continue on.

$scope.checkNum = function() {
 // var a = angular.element(document.querySelector('[widget-id="popup-1"] 
  div')).scope().$parent.me.visible
var inputs = document.getElementsByTagName("input");
//or document.forms[0].elements;
var cbs = [];
//will contain all checkboxes
var checked = [];
//will contain all checked checkboxes
  for (var i = 0; i < inputs.length; i++) {

  if (inputs[i].type == "checkbox") {
    cbs.push(inputs[i]);
    if (inputs[i].checked) {
      checked.push(inputs[i]);
    }

}
}
 var nbCbs = cbs.length;
 //number of checkboxes
 var nbChecked = checked.length;
   //number of checked checkboxes
    alert("# checkboxes = " + nbCbs + "\n" +  "# checked checkboxes = " + 
    nbChecked);
    console.log(" # checked checkboxes = " + nbChecked);
}




WP All Import - ACF checkboxes / Typing in the value

I have an issue while I am importing data for adding new vehicles for our car dealer plugin.

I have a set of checkboxes for instance for the exterieur-color of the vehicle. View the attached images.

Example1

Example2

My Question: What I have to type in into the field, that the color "Silber" is selected and not added as an another value?

Thank you very much!

Here is a sample of the sourcecode:

<div id="acf-color" class="field field_type-radio field_key-eab5f6206e77e9e1aab51ad04477a822" data-field_name="color" data-field_key="eab5f6206e77e9e1aab51ad04477a822" data-field_type="radio"><p class="label"><label for="acf-field-color">Außenfarbe</label></p><ul class="acf-radio-list radio vertical"><li><label><input id="acf-field-color-Silber" type="radio" name="fields[eab5f6206e77e9e1aab51ad04477a822]" value="Silber" />Silber</label></li><li><label><input id="acf-field-color-Schwarz" type="radio" name="fields[eab5f6206e77e9e1aab51ad04477a822]" value="Schwarz" />Schwarz</label></li><li><label><input id="acf-field-color-Weiss" type="radio" name="fields[eab5f6206e77e9e1aab51ad04477a822]" value="Weiss" checked=&quot;checked&quot; data-checked=&quot;checked&quot; />Weiss</label></li>




samedi 29 décembre 2018

Add and Remove selected items of a checkbox from java ArrayList in Android

I have a function that dynamicaly builds checkboxes according to the values of an ArrayList,

Now I want to add those items to another ArrayList when checked and Remove them when Uncheck.

Adding when Item is checked is working but when I uncheck the checkbox it gives an error.

public void BuildCheckBox(){

    FinalSeatList.removeAll(FinalReservedSeatList);

    //Build checkboxus
    LinearLayout l1 = (LinearLayout)findViewById(R.id.linear_view);
    for(int i = 0; i < FinalSeatList.size(); i++) {
        final CheckBox cb = new CheckBox(this);
        cb.setText(FinalSeatList.get(i));
        l1.addView(cb);
        final int finalI = i;
        cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (buttonView.isChecked()) {
                    SelectedSeatList.add(FinalSeatList.get(finalI));
                    Toast.makeText(SelectSeatsActivity.this, "Added: " + SelectedSeatList.get(finalI), Toast.LENGTH_SHORT).show();
                }
                else
                {
                    if(SelectedSeatList.contains(FinalSeatList.get(finalI))){
                        SelectedSeatList.remove(FinalSeatList.get(finalI));
                        Toast.makeText(SelectSeatsActivity.this, "Removed: " + SelectedSeatList.get(finalI), Toast.LENGTH_SHORT).show();
                    }else{
                        Toast.makeText(SelectSeatsActivity.this, "Unchecked", Toast.LENGTH_SHORT).show();
                    }


                }
            }

        });
    }




}




Checkbox input doesn't get centered along with the label

The text-center centers the label "check this custom checkbox" but the input remains on the left.

If you remove that custom-control-input class then you will see a new checkbox input which will be centered and the bootstrap input will still be there on the left and it will be unclickable.

I want to center the whole thing.

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <div class="custom-control custom-checkbox text-center">
      <input type="checkbox" class="custom-control-input" id="customCheck1">
      <label class="custom-control-label" for="customCheck1">Check this custom checkbox</label>
    </div>



Clone checkbox when checked

I want to be able to clone a checkbox when it is clicked, and the cloned checkbox will be unchecked. When the cloned checkbox is checked, it will clone itself and the process repeats.

                        <section class="misc"> 
                    <div class="row">
                     &nbsp;&nbsp;&nbsp;&nbsp;
                     <label class="label"><input type="checkbox" class="others"> Others:</label>                     
                    </div>           

                    <div class="row">
                     <div class="col-md-6"><input type="text" class="form-control" placeholder="Others"/></div>                          
                    </div>
                    </section>
                    <div class="sth"></div>

                <!-- Clone the "Others" checkbox with textbox when the original checkbox is checked. I want each subsequent clone to be unchecked, then clone itself.. -->
                <script>
                $(".others").change(function(){

                 if($(this).is(':checked'))
                    {
                        var clone=$(this).parents('section').clone();
                        $('.sth').html(clone);
                    }

                });</script>

Right now, I'm only able to clone the original and the cloned checkbox is checked instead of unchecked.

Jsfiddle: http://jsfiddle.net/cLkvxydh/




vendredi 28 décembre 2018

Cross filtering with multiple checkbox categories in d3

I would like to filter data in a d3 map using two different checkbox categories, one for "tenant" and one for "broker". I can filter successfully by either category by itself, but the issue I'm having is getting both filters to work together. For example, if I re-check a box in one category it will bring back all the data for that category, regardless of what is checked/unchecked in the other category. I'd like to filter data on multiple categories at once. Here's my code:

//"Tenant" checkboxes
<div class="Regus" style="margin-right:30px; margin- 
    top:13px">Regus
    <input class ='tenantcheck' type="checkbox" 
    id="RegusCheckbox"  checked/>
    <label  for="RegusCheckbox"></label>
</div>

<div class="Spaces" style="margin-right:30px; margin-top:13px">Spaces
    <input class ='tenantcheck' type="checkbox" id="SpacesCheckbox"  checked/>
    <label  for="SpacesCheckbox"></label>
</div>


//"Broker" checkboxes
<label class="container" >CBRE
    <input class ='agencyBrokerCheck' type="checkbox" id="CBRECheckbox" checked >
    <span class="checkmark"></span>
</label>

<label class="container" >Colliers
    <input class ='agencyBrokerCheck' type="checkbox" 
    id="ColliersCheckbox" checked >
    <span class="checkmark"></span>
</label>

//Filter by "Tenant"
d3.selectAll("#RegusCheckbox").on("change", function() {
            var type = "Regus"
            display = this.checked ? "inline" : "none";
            d3.selectAll(".features")
            .filter(function(d) { return d.properties.Tenant === type; })
            .attr("display", display);
            });

d3.selectAll("#SpacesCheckbox").on("change", function() {
            var type = "Spaces"
            display = this.checked ? "inline" : "none";
            d3.selectAll(".features")
            .filter(function(d) { return d.properties.Tenant === type; })
            .attr("display", display);
            });

//And, filter by "Broker"
d3.selectAll("#CBRECheckbox").on("change", function() {
            var type = "CBRE"
            display = this.checked ? "inline" : "none";
            d3.selectAll(".features")
            .filter(function(d) { return d.properties.Agency_Bro === type; })
            .attr("display", display);
            });
d3.selectAll("#ColliersCheckbox").on("change", function() {
            var type = "Colliers International"
            display = this.checked ? "inline" : "none";
            d3.selectAll(".features")
            .filter(function(d) { return d.properties.Agency_Bro === type; })
            .attr("display", display);
            });

Is there a way to keep this general logic while allowing d3 to filter by both these categories at once? Thanks in advance.




Programming an inspection form

I am creating an inspection form and would like checkboxes to populate based on the value of another box. For example, the Total Score of the inspection would, based on its value, allow a checkbox to populate whether the inspection is Green, Amber, or Red.

Also, I would like that when a checkbox is checked, it populates the associated point value for that section that then translates to the overall assessment area.

I know this is a lot to ask but Googling the answers doesn't seem to be helping me.

Thank you in advance for any and all assistance.




chekboxes for filtering data in VBA

I am relatively new to VBA and I would need your help with something. I have huge excel sheet with many columns and I would like to do a small tool which allows you to filter 4 different columns by checking the checkboxes containing the criteria. The first column I would like to filter has 12 criteria, the second has 33, the third 6 and the fourth 44. The user chooses some of the criteria for each filter and by clicking a button must be able to have the worksheet filtered and soma calculations are automatically done with the filtered data.

I have been able so far to do this just for one filter, but I can't seem to succeed when I try it for the other columns. Here is my code so far which works only for one filter. Is there any way I can adapt it in order to filter all the columns?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("B2:B13")) Is Nothing Then Exit Sub
    Target.Font.Name = "marlett"
If Target.Value <> "a" Then
    Target.Value = "a"
    Cancel = True
    Exit Sub
End If
If Target.Value = "a" Then
    Target.ClearContents
    Cancel = True
    Exit Sub

End If End Sub

Sub Filter_Me1()

Dim LR As Long
Dim cBox As Variant
Dim cel As Range
ReDim cBox(0)
With Sheets("S0002")
    .AutoFilterMode = False
    LR = .Cells.Find("*", .Cells(Rows.Count, .Columns.Count),_
    SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    For Each cel In Sheets("Sheet1").Range("B2:B13")
        If Not cel.Value = "" Then
            cBox(UBound(cBox)) = cel.Offset(0, -1).Value
            ReDim Preserve cBox(UBound(cBox) + 1)
        End If
    Next cel

    If IsError(Application.Match("*", (cBox), 0)) Then
        MsgBox "Nothing Selected"
        Exit Sub
    End If

    ReDim Preserve cBox(UBound(cBox) - 1)
    If Not .AutoFilterMode Then
        .Range("B2").AutoFilter
        .Range("A1:Z" & LR).AutoFilter Field:=2, Criteria1:=Array(cBox),_
         Operator:=xlFilterValues
    End If
End With

End Sub




Two checkbox in recyclerview changing state when scrolling

I am working on fantasy cricket app where i am selecting captain and vice captain from the list of 11 player. I am using checkbox for selecting captain and vice captain. The selection of checkbox is working fine with my code, but the issue is when I select 1st player as a captain(C) and 2nd player as Vice-Captain(VC) and then scroll the list the checkbox state changing and showing other player selected. So is there any right way to do that thing. I have tried many way they are working when there is single checkbox but in my case there is two and only one can be select from the list.

Please refer to the attached screenshots for more understanding.

Adapter Class

public class AdapterFinalTeamList extends     RecyclerView.Adapter<AdapterFinalTeamList.MyViewHolder> {
    private List<BeanDBTeam> mListenerList;
    Context mContext;
    private  CheckBox lastChecked = null;
    private  int lastCheckedPos = 0;

    private  CheckBox lastChecked2 = null;
    private  int lastCheckedPos2 = 0;

    private RadioButton lastCheckedRB = null;
    private RadioButton lastCheckedRB1 = null;

    TextView PreviousCaptain = null;
    TextView PreviousVC = null;


    public AdapterFinalTeamList(List<BeanDBTeam>              mListenerList, Context context) {
        mContext = context;
        this.mListenerList = mListenerList;

    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        TextView tv_PlayerName,tv_SelectCaptain,tv_SelectViceCaptain, tv_PlayerTeamName, tv_PlayerPoints,tv_TeamNumber;
        ImageView im_PlayerImage,im_onetwox;
        CheckBox checkbox,checkbox2;

        RadioGroup radiogroup;
        RadioButton radio,radio2;


        public MyViewHolder(View view) {
            super(view);

            tv_PlayerName =view.findViewById(R.id.tv_PlayerName);
            tv_PlayerTeamName = view.findViewById(R.id.tv_PlayerTeamName);
            tv_PlayerPoints = view.findViewById(R.id.tv_PlayerPoints);

            im_PlayerImage = view.findViewById(R.id.im_PlayerImage);
            im_onetwox = view.findViewById(R.id.im_onetwox);


            tv_TeamNumber = view.findViewById(R.id.tv_TeamNumber);
            tv_SelectViceCaptain = view.findViewById(R.id.tv_SelectViceCaptain);
            tv_SelectCaptain= view.findViewById(R.id.tv_SelectCaptain);
            checkbox= view.findViewById(R.id.checkbox);
            checkbox2= view.findViewById(R.id.checkbox2);
            radiogroup= view.findViewById(R.id.radiogroup);
            radio= view.findViewById(R.id.radio);
            radio2= view.findViewById(R.id.radio2);

        }

    }

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

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.adapter_final_list, parent, false);

        return new MyViewHolder(itemView);
    }



    @Override
    public void onBindViewHolder(final MyViewHolder holder, final int position) {



        String id = mListenerList.get(position).getMatchId();

        String arrayList = (mListenerList.get(position).getPlayerData());
        try {
            JSONObject job = new JSONObject(arrayList);

            String PlayerName = job.getString("name");
            String PlayerImage = job.getString("image");
            String PlayerPoints = job.getString("player_points");
            String PlayerCredit = job.getString("credit_points");
            String TeamShortName = job.getString("team_short_name");

            String team_number = job.getString("team_number");
            String player_shortname = job.getString("player_shortname");
            holder.tv_TeamNumber.setText(team_number);
            // PlayerTeam= job.getString("short_name");

            holder.tv_PlayerName.setText(PlayerName);

            holder.tv_PlayerPoints.setText(PlayerPoints);
            holder.tv_PlayerTeamName.setText(TeamShortName);


            Glide.with(activity).load(Config.PLAYERIMAGE + PlayerImage)
                    .crossFade()
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .into(holder.im_PlayerImage);

        } catch (JSONException e) {
            e.printStackTrace();
        }
holder.checkbox.setChecked(mListenerList.get(position).isSelected());
        holder.checkbox.setTag(new Integer(position));

        holder.checkbox.setChecked(mListenerList.get(position).isSelected2());
        holder.checkbox2.setTag(new Integer(position));



        holder.checkbox.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v) {

                CheckBox cb = (CheckBox) v;
                int clickedPos = ((Integer) cb.getTag()).intValue();
                    holder.checkbox2.setChecked(false);

                    if (cb.isChecked()) {
                        if (lastChecked != null) {
                            mListenerList.get(lastCheckedPos).setSelected(false);
                            lastChecked.setChecked(false);
                        }
                        else if (clickedPos==position){
                            lastCheckedPos = clickedPos;
                            lastChecked = cb;
                            lastChecked.setChecked(true);
                        }
                        lastCheckedPos = clickedPos;
                        lastChecked = cb;
                    } else
                        lastChecked = null;

                    try {
                        lastChecked.setChecked(true);
                    }
                    catch (Exception e){
                        e.printStackTrace();
                    }

                    mListenerList.get(clickedPos).setSelected(cb.isChecked());
                    CaptainId = mListenerList.get(position).getPlayerId();


            }
        });
    holder.checkbox2.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v) {
                CheckBox cb = (CheckBox) v;
                int clickedPos = ((Integer) cb.getTag()).intValue();

                holder.checkbox.setChecked(false);

                    if (cb.isChecked()) {
                        if (lastChecked2 != null) {
                            lastChecked2.setChecked(false);
                            mListenerList.get(lastCheckedPos2).setSelected(false);
                        }
                        else if (clickedPos==position){
                            lastChecked2 = cb;
                            lastCheckedPos2 = clickedPos;
                            lastChecked2.setChecked(true);
                        }

                        lastChecked2 = cb;
                        lastCheckedPos2 = clickedPos;
                    } else
                        lastChecked2 = null;

                    try{
                lastChecked2.setChecked(true);
                    }
                    catch (Exception e){
                        e.printStackTrace();
                    }
                    mListenerList.get(clickedPos).setSelected2(cb.isChecked());
                ViceCaptainId = mListenerList.get(position).getPlayerId();

                }

        });


    }

}

adapter_final_list.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res /android"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="wrap_content">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="2dp"
    android:padding="5dp"
    android:id="@+id/RL_PlayerListMain"
    android:elevation="0dp">

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/tv_TeamNumber"

    android:visibility="invisible"/>
<ImageView
    android:layout_width="50dp"
    android:layout_height="50dp"
    android:src="@drawable/logo"
    android:layout_centerVertical="true"
    android:id="@+id/im_PlayerImage"/>
<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:id="@+id/RL_Name"
    android:layout_toRightOf="@+id/im_PlayerImage"
    android:layout_marginLeft="10dp">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Player Name"
    android:id="@+id/tv_PlayerName"
    android:textColor="#1e1e1e"
    />
<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center"
    android:layout_below="@+id/tv_PlayerName">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="IND"
        android:layout_gravity="center"
        android:layout_marginRight="5dp"
        android:id="@+id/tv_PlayerTeamName"
        android:textColor="#1e1e1e"
        />
    <View
        android:layout_width="1dp"
        android:layout_height="10dp"
        android:layout_gravity="center"
        android:background="#8e8e8e"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="55 Points"
        android:layout_gravity="center"
        android:id="@+id/tv_PlayerPoints"
        android:textColor="#8e8e8e"
        android:layout_marginLeft="5dp"
        />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:id="@+id/RL_Credit"
    android:layout_alignParentRight="true">
    <TextView
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:text="C"
        android:padding="10dp"
        android:textAlignment="center"
        android:gravity="center"
        android:visibility="gone"
        android:layout_centerVertical="true"
        android:background="@drawable/circle_captain_vc_back"
        android:id="@+id/tv_SelectCaptain"
        android:textColor="#1e1e1e"
        android:layout_marginLeft="10dp"
        />

    <CheckBox
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_toRightOf="@+id/tv_SelectViceCaptain"
        android:layout_centerVertical="true"
        android:visibility="visible"
        android:text="C"
        android:textColor="#1e1e1e"
        android:gravity="center"
        android:button="@android:color/transparent"
        android:background="@drawable/radio_selector"
        android:id="@+id/checkbox"/>
    <CheckBox
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_toRightOf="@+id/checkbox"
        android:layout_centerVertical="true"
        android:visibility="visible"
        android:text="VC"
        android:layout_marginLeft="5dp"
        android:textColor="#1e1e1e"
        android:gravity="center"
        android:button="@android:color/transparent"
        android:background="@drawable/radio_vc_selector"
        android:id="@+id/checkbox2"/>

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/onex_icon"
        android:visibility="invisible"
        android:layout_centerHorizontal="true"
        android:id="@+id/im_onetwox"
        />

    <RadioGroup
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/radiogroup"
        android:visibility="gone"
        android:layout_marginTop="10dp"
        android:layout_below="@+id/im_onetwox"
        android:orientation="horizontal">
    <RadioButton
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_toRightOf="@+id/tv_SelectViceCaptain"
        android:layout_centerVertical="true"
        android:visibility="visible"
        android:text="C"
        android:layout_marginRight="10dp"
        android:gravity="center"
        android:background="@drawable/radio_selector"
        android:button="@android:color/transparent"
        android:id="@+id/radio"/>
    <RadioButton
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_toRightOf="@+id/checkbox"
        android:layout_centerVertical="true"
        android:visibility="visible"
        android:text="VC"
        android:gravity="center"
        android:background="@drawable/radio_vc_selector"
        android:button="@android:color/transparent"
        android:id="@+id/radio2"/>
    </RadioGroup>



    <TextView
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:text="VC"
        android:textAlignment="center"
        android:gravity="center"
        android:visibility="gone"
        android:padding="10dp"
        android:layout_toRightOf="@+id/tv_SelectCaptain"
        android:layout_centerVertical="true"        android:background="@drawable/circle_captain_vc_back"
        android:id="@+id/tv_SelectViceCaptain"
        android:textColor="#1e1e1e"
        android:layout_marginLeft="10dp"
        />


</RelativeLayout>

</RelativeLayout>

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#8e8e8e"
    android:layout_marginTop="5dp"
    android:layout_marginBottom="2dp"
    android:layout_marginRight="5dp"
    android:layout_marginLeft="5dp"
    android:layout_below="@+id/RL_PlayerListMain"/>
 </RelativeLayout>

1. Selecting C and VC

2. After scrolling top to bottom and bottom to top.

Please ignore Radio group. My code is working fine with checkbox only creating issue when scroll.




Laravel - Highlighting roles which are already assigned to a user

On user\edit view I'm displaying all roles as checkboxes. I'd like to have roles which are already assigned to a user checked. All other fields in the form are filled in with details from the database already. I'm trying to work with Spatie's Laravel Permissions.

Image of the view

@foreach ($roles as $role)
    <input type="checkbox" value="" name="" > </input>
@endforeach

I would like to use pure HTML. I read about eager loading but from what I understood it will give me only roles assigned to a user, not all of them.

I want to use sychRoles() function when I click update button. I was hoping to build similar view to what Voyager uses: example.




How to use ternary operator for checkbox in haml?

I am confused about how to use the haml syntax for ternary operator to check if a checkbox is checked or not. I have a color_id column which stores values based on which checkbox is checked. Below is my code:

  .dress_color
    .form-group
    .checkbox.checkbox-primary.color_id
     = f.check_box :color_id, {}
     %label= t('.dark color')

    - if f.object.long_dress_selected?
          ...............
    - else
      = f.check_box, checked: true ? ('color_id: black') : ('color_id: white')

I want to check whether the 'dark_color' check box is checked or not, in the else part of the if-else condition. That is, if the checkbox is checked, color_id should be set to 'black' else it should be set to 'white'. But the above code is showing error as:

SyntaxError -html.haml:19: syntax error, unexpected tLABEL, expecting '='
_false(( f.check_box, checked: true ? ('color_id
                              ^:

How to check the whether the checkbox is checked or not by using ternary operator?

Thanks in advance.




jeudi 27 décembre 2018

Is there any way in Redux form to have checkbox with three options, like positive, negative and not selected?

I am working on a form with three way checkbox - positive, negative or not selected.

I am wondering if is there any good examples of doing that with redux-form Field.

Any help would be appreciated, thanks.




Rails edit form check box not checking the boolean true value

I have a following code in user's edit page.

  = form_for @user do |f|
    .row
      .col-sm-4.col-md-4
        = f.label :pay_via_zelle, 'Pay Via Zelle:'
        = f.check_box :pay_via_zelle
    .row
      .col-sm-12.col-md-4
        = f.submit "Update", class: 'btn btn-primary form-control'

@user object's pay_via_zelle is true in database.

But the problem is when I visit the users edit page, the checkbox is supposed to be checked, but it is not.

Here is the html output generated by above form

<form class="edit_agent" id="edit_agent_162" action="/agents/38285" accept-charset="UTF-8" method="post">
  <input name="utf8" type="hidden" value="✓">
  <input type="hidden" name="_method" value="patch">
  <input type="hidden" name="authenticity_token" value="OdozGg7J1UvlhX0Nol05mHRFAGCgIji5cxYXlprqS62/BUwtaIU7hb+rhem0zE7hIrnzLXRyzfpi1fmSlT9a9A==">
  <div class="row">
    <div class="col-sm-4 col-md-4">
      <label for="agent_pay_via_zelle">Pay Via Zelle:</label>
      <input name="agent[pay_via_zelle]" type="hidden" value="0">
      <input type="checkbox" value="1" checked="checked" name="agent[pay_via_zelle]" id="agent_pay_via_zelle">
    </div>
  </div>
  <div class="row">
    <div class="col-sm-12 col-md-4">
      <input type="submit" name="commit" value="Update" class="btn btn-primary form-control" data-disable-with="Update">
    </div>
  </div>
</form>

The checkbox has checked='checked' property, but the checkbox is not checked.

Have I missed anything?




how to uncheck/check a primeng checkbox manually

html

          <p-checkbox name="showLinkedRisksOnly" id="showLinkedRisksOnlyChkBx" label="Show Only Linked Risks" binary="true" (click)="showOnlyLinkedRisks($event)"
                      [ngModel]="showLinkedRisksOnly" ></p-checkbox>

typescript

showOnlyLinkedRisks($event){
  if(condition){
    this.showLinkedRisksOnly = !this.showLinkedRisksOnly;
  }
}

I am trying to change the state of checkbox back to before it was checked/unchecked based on condition. But for some reason the checkbox and model get out of sync when I do change the value of this.showLinkedRisksOnly. Is it possible to achive




Display Datagridview dynamically created chechboxvalue? c#

I stored the value of my dynamically created Checkboxes and now I want to display the stored value upon reload of the windowsform. I tried various versions but none work out. They all change the value to "true" but it doesn't get displayed! I put the code for test purposes directly after creating each checkbox column but it still doesn't show...Please help

foreach (DataGridViewRow row in WarDataGridView.Rows)
  {
    for (int col = 1; col < WarDataGridView.ColumnCount; col++)
    {
     (WarDataGridView.Rows[row.Index].Cells[col] as DataGridViewCheckBoxCell).Value = true;

    }
  }




Angularjs pass ng-repeat checkbox value undefined

This question asked already but that not solve my issue.

Am trying to pass checkbox value to controller but i got undefined message. Am beginner in Angularjs.

This is my HTML code:

<form class="form-horizontal" name="addForm" novalidate ng-submit="addData(addForm)">
    <div class="form-group">
        <div class="col-sm-3" ng-repeat="directories in formData.getMainDirectories">
            <input type="checkbox" ng-model="directories.main_directories_id.selected" value=""><span>  </span>
        </div>
    </div>
    <button type="submit" class="btn btn-primary btn-md" button-spinner="loading" ng-disabled="loading">Submit</button>
</form>

My .js code:

$scope.addData = function(form)
{
    $scope.errors = [];
    alert(form.main_directories_id); // alert here
    if(form.$valid)
    {
        $rootScope.loading = true;

        webServices.upload('create', $scope.formData).then(function(getData) {
            $rootScope.loading = false;
            if (getData.status == 200) {
                $sessionStorage.successmessage = getData.data.message;
                localStorage.directory = '';
                $scope.goback();
            } else if (getData.status == 401) {
                $scope.errors = utility.getError(getData.data.message);
                $scope.showerrors();
            } else {
                $rootScope.$emit("showerror", getData);
            }
        });
    }
}

$scope.getMainDirectories = function()
    {
        webServices.get('getMainDirectories').then(function(getData) 
        {
            $rootScope.loading = false;
            if (getData.status == 200) 
            {
                $scope.formData.getMainDirectories = getData.data;
            } else {
                $rootScope.$emit("showerror", getData);
            }
            //console.log(getData.data);
        });
    }

Image: enter image description here




mercredi 26 décembre 2018

Problem with select all tri-state checkboxes

I have a list of checkboxes - two parents and each parent has 5 childs. The parents should have 3 states (checked,unchecked,indeterminate). Right now, my code is working BUT I'm trying to add a 'select all' checkbox , which will select the two parents and all their childs.

What I tried to do is adding one more label above:

    <label>
    <input type="checkbox" data-indeterminate-checkbox data-child- 
     list="model.people" data-property="eaten" data-ng- 
     model="model.allEaten"> All eaten
    </label>

but it's not working - the checkbox is not acting as expected.

Full code: http://jsfiddle.net/wnjze03h/210/




How to get an array of multi checkbox on ionic4?

I'm trying to get an array with a multi checkbox on ionic 4, can someone help me?

        <ion-item>
          <ion-label position="floating">0</ion-label>
          <ion-checkbox  color="primary" value="0"></ion-checkbox>
        </ion-item>

        <ion-item>
          <ion-label position="floating">1</ion-label>
          <ion-checkbox color="secondary" value="1"></ion-checkbox>
        </ion-item>

        <ion-item>
          <ion-label position="floating">2</ion-label>
          <ion-checkbox color="danger" value="2"></ion-checkbox>
        </ion-item>

        <ion-item>
          <ion-label position="floating">3</ion-label>
          <ion-checkbox color="light" value="3"></ion-checkbox>
        </ion-item>



Add terms & conditions checkbox only on Woocommerce registration page

Using Add a terms and conditions checkbox in woocommerce registration form answer thread allow adding a terms & conditions checkbox on registration page, but this also enable the default term and conditions on checkout page.

How to have Terms & Conditions Checkbox On Registration Only?

Any help is truly appreciated.




mardi 25 décembre 2018

I need a help to change checkbox state when I change sheet with each different state in EXCEL VBA

I am developing some VBA macro that has Ribbon checkbox. How can I change a checkbox state when I change sheet with each different state in EXCEL VBA. I use a callback function "Workbook_sheetAcivate" at workbook module. But I can't control checkbox state at this module.




CheckBox setChecked(true) simply isn't working

I have a checkbox, defined as such in XML:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#FFF"
    android:orientation="vertical">

    <RelativeLayout
        android:id="@+id/item1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FFF">

        <CheckBox
            android:id="@+id/checkbox_monitor"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:text="Monitor (present and restocked)"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="6dp"
            android:layout_marginLeft="16dp"
            android:layout_marginBottom="6dp"/>
    </RelativeLayout>
    ...
</LinearLayout>

This LinearLayout is made up of ten similar RelativeLayouts and is embedded within a ScrollView, if that makes any difference.

Here is the corresponding Activity:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_eos);
    setTitle("End of Shift Check-Off");

    setToolbarColor();
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Checkboxes
    CheckBox cbMonitor = findViewById(R.id.checkbox_monitor);
    cbMonitor.setChecked(true);
    ....
}

Simply put, the setChecked() function does not work. Initially, I assumed my condition was not returning true, but the function on its own does not work and I have no idea why. I have been searching for hours, any help or feedback at all is greatly appreciated.




lundi 24 décembre 2018

Custom checkbox in bootstrap 4.1.x

I require a checkbox like this one or similar

enter image description here

There are lots of answers about styling checkboxes but none worked in bootstrap 4.1.x, either I am using them wrong or they are not working in this bootstrap version.




after updatepanel.update, the style of the checkbox will be removed

How can I fix this problem? When updatepanel.update, the checkbox or radiobutton style will disappear my hmtl:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableCdn="True"></asp:ScriptManager>

<asp:UpdatePanel ID="upnl_1" runat="server">
    <ContentTemplate>
       <asp:DropDownList ID="ProjectsList_ddl" runat="server" AutoPostBack="true"
                             OnSelectedIndexChanged="ProjectsList_ddl_SelectedIndexChanged">
       </asp:DropDownList>                                              
    </ContentTemplate>

<asp:UpdatePanel ID="upnl_2" runat="server">
 <ContentTemplate>
       <asp:Repeater ID="toolsList_rpt" runat="server">
          <ItemTemplate>
              <input id="myradio" runat="server" type="radio" name="drone" class="flat">
                     <span><%#Eval("Title")%></span>   
          </ItemTemplate>
       </asp:Repeater>                                                           
     <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upnl_1" DisplayAfter="0">
    <ProgressTemplate>                                                      
     <asp:Image ID="img" runat="server" ImageUrl="/loader.gif"  />                                                         
    </ProgressTemplate>
   </asp:UpdateProgress>
  </ContentTemplate>

before load data (updatepanel.update & toolsList_rpt.bind)

after thanks everyone




Flutter Checkbox Animation Not Showing

So I have a ListView of ListTiles and every tile has a checkbox in it. I can change the state of the checkboxes just fine but the proper animation does not show. What am I missing here? Thanks!

Widget _buildListTile(BuildContext context, Task item) {
return Dismissible(
  // Show a red background as the item is swiped away
  background: Container(color: Colors.red),
  key: Key(item.hashCode.toString()),
  onDismissed: (direction) {
    setState(() {
      tasks.remove(item);
    });
  },
  child: ListTile(
    leading: Checkbox(
      value: item.checked,
      onChanged: (bool newValue) {
        setState(() {
          item.checked = newValue;
        });
      },
      activeColor: Colors.blue,
    ),
    title: InkWell(
        onTap: () {
          editTask(item);
        },
        child: Text(
          item.task,
          style: TextStyle(fontSize: 18),
        )),
    contentPadding: EdgeInsets.all(8),
    //trailing: Icon(Icons.drag_handle),
  ),
);
}




Variable input detection

I am making a very repetitive form with a lot of check boxes that all interact relatively the same and was wondering if there was any way to have variable input detection such as,

Checkbox{X}.checkedchanged
Textbox{X}.text = "Example";
Count{X}++;

I have a lot of variable and text boxes that interact in the same way but relative to each other.




dimanche 23 décembre 2018

Open a link and active a checkbox

Im trying to create an element, which when clicked, both opens a hyperlink and actives a label connected to a checkbox. The element is a menu item. When that menu item is clicked, I want the anchor/link to be opened and the menu to be closed through CSS, hence the checkbox.

However, whenever I put the label inside the hyperlink, the checkbox gets checked, but the hyperlink does not get opened.

<a href="#anchor">
    <label for="checkbox">
        Menu Item
    </label>
</a>

When I put the hyperlink inside the label, the opposite happens: the link gets opened, but the checkbox does not get checked.

<label for="checkbox">
    <a href="#anchor">
        Menu Item
    </a>
</label>

Is it possible to active the label and open the hyperlink simultaneously without using JavaScript? If so, how?




vendredi 21 décembre 2018

Is it possible to send checkbox data to a database?

I need to know if it is actually possible to send checkbox data to database.

I don't understand why im getting down votes im just asking if it's possible!




Ajax Checkbox post on change with multiple ID's on one page

Im trying to post the status of all rows on change checkbox status, but it doesnt work at the moment. Where is the problem i cant see ?

My ajax request code is above ;

<script>

$( document ).ready(function() {
$("checkbox[id^=number]").change (function () {

var value = $(this).val();

if (confirm("Are You Sure ?")){

$.ajax({
    type: "POST",
    url: "ajaxislem.php?islem=teslimat",
    async: true,
    data: {
        ilid: $(this).data("id") 
    },
    success: function (msg) {



         $('.onayli').html(msg).show(); 

    }
});

  }
}) ;});
</script>

And my checkboxes above :

<label><input id="number1" data-id="1" checked type="checkbox" checked> <b><span class="onayli"><font color="green"> Açık</font></span></b> </label>
    <label><input id="number2" data-id="2" checked type="checkbox"  checked> <b><span class="onayli"><font color="green"> Açık</font></span></b> </label>
    <label><input id="number3" data-id="3" checked type="checkbox"  checked> <b><span class="onayli"><font color="green"> Açık</font></span></b> </label>




Contact Form 7 add line breaks in multiple checkboxes in email

I have a CF7 form where I have multiple checkboxes and the user has to select at least one option. Here is the code I'm using.

[checkbox* checkbox-380 use_label_element "option1" "option2" "option3"]

Everything is working. But when the form is submitted the result in the email display the selected checkboxes in one line separated by commas like below:

option1, option2, option3.

But I want each item to be displayed in a new line like this: option1 option2 option3

Is it doable?

Thanks in advance.




Question on multiple checkboxes launching code

I have a user form and a frame with 35 checkboxes in it, numbered 1 to 35. They represent 35 Named Ranges. I test to see if any of the name ranges are not set, if set correctly the checkbox value is set to TRUE.

I found some code that would allow me to trigger a sub if one of the checkboxes is clicked. That code seems to work, but my check code above also triggers the checkbox events, which I do not want. I only want the sub to run when the checkbox is clicked with the mouse? I can post the code I'm using, but though I'd first ask the question to see if what I would like to do is possible.

Thanks, Jim




Word VBA - Expand a header if a certain checkbox is ticked?

Used VB for Excel, but new to VB for Word. I'm not sure how to expand a header if a certain checkbox is marked true.

ActiveDocument.FormFields("Check1").CheckBox.Value = True

I got that snippet straight from Microsoft Document and dropped it in a If statement and still get an error. Then, I don't know how to reference a specific header and execute the expand. All I have there is Collapse/Expand all headers.




Make input checkbox update when clicked, not when data is done

There is an input checkbox which can be clicked to be checked or unchecked:

<input
    type="checkbox" 
    ng-model="$ctrl.checkedOrNot"
    ng-change="$ctrl.doSomething()"
/>


doSomething() {
    this.MyService.setInput(this.checkedOrNot);
    if(this.loading) return;
    this.doStuff();
    this.doOtherStuff();
}

For the moment the check appears only after all the calls from doSomething are done. Is there a way to make it appear right when it's clicked?




How to get Iphone checkboxes in Internet explorer and edge?

I have the following css:

input.apple-switch {
    position: relative;
    -webkit-appearance: none;
    outline: none;
    width: 50px;
    height: 30px;
    background-color: #fff;
    border: 1px solid #D9DADC;
    border-radius: 50px;
    box-shadow: inset -20px 0 0 0 #fff;
}

input.apple-switch:after {
    content: "";
    position: absolute;
    top: 1px;
    left: 1px;
    background: transparent;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    box-shadow: 2px 4px 6px rgba(0,0,0,0.2);
}

input.apple-switch:checked {
    box-shadow: inset 20px 0 0 0 #4ed164;
    border-color: #4ed164;
}

input.apple-switch:checked:after {
    left: 20px;
    box-shadow: -2px 4px 3px rgba(0,0,0,0.05);
}

input[type="checkbox"]:focus{
                outline:0;
            }

HTML:

        <label class="col-xs-12">
            Success
        </label>
        <div class="col-xs-12">
            <input class="apple-switch successChk" type="checkbox" checked="checked">
        </div

This works in chrome but in IE and edge it looks like this: enter image description here

Css is not my strong side and the code above is something I found.

Is there anything I can do to get the iphone-switch-checkbox

In ie and edge aswell?




jeudi 20 décembre 2018

Checkbox returns the one value even after everything is unselected

I have a small query. Here I have 5 checkboxes and I want to display the value of the selected checkbox in a input tag. Everything is working fine however whenever I uncheck all the boxes, The input always returns the value of the last unchecked checkbox. What I want is when I uncheck all the checkboxes, The input tag should be empty. I have tried 'if' statement to clear the input when every box is empty but it sometimes work unexpectedly.I am using jQuery as a javascript library. Kindly guide. Thank you.

Check Example value 1 value 2 value 3 value 4 value 5
<input type="text" id="checkVal">

<script>
    $('.checkbox_ss').click(function(){
        var text = '';
        $('.checkbox_ss:checked').each(function(){
            text += $(this).val();
            $('#checkVal').val(text);
        });
    });
</script>




Kendo UI - Javascript checkbox value submit to DataSource read

I was newbie in Kendo Ui and also javascript programming. I have a simple question how to submit the value from my checkbox to dataSource transport : read?

so "getMarketData.php" able to get "c1" value (active) and reload in the same page again.

Here I provide my code? Hope someone can help me. Thank You.

My checkbox :

<input type="checkbox" id="c1" name="checkbox1" class="k-checkbox" checked="checked" value="active" onclick="checkBox()">

My Javascript

<script>

$(function() {
    var dataSource = new kendo.data.DataSource({
                transport: {
                    read: {
                        url: "/getMarketData.php",
                        type: "POST"
                    }
                },
                schema: {
                    model: {
                        id: "marketID"
                    }
                }
    });
});

function checkBox() {

    var checkbox = document.getElementById("c1");

    if (checkbox.checked == true) { 
        //pass "active" data
        $("#grid").data("kendoGrid").refresh();
        $("#grid").data("kendoGrid").dataSource.read();     
    } else {    
        if (checkBox.value == 'active') {
            var x = 'inactive';
        }
        //pass "inactive" data
        $("#grid").data("kendoGrid").refresh();
        $("#grid").data("kendoGrid").dataSource.read();
    }
}




Add/Remove data from empty array using checklist-model

I have a checklist-model form (multiple checkboxes) in AngularJS that needs to read/add/remove values from an array. The array may have no value or it may have five values. The array values are 20,21,22,23,24. Each value corresponds to the five check boxes. If the array contains '20' then the checkbox input for '20' will be checked, etc...

If I use ng-model instead of checklist-model, it works. The checkbox is checked upon loading the form because formData.observations == 20. When I uncheck the box 20 is removed from the formData.observations array as expected.

When I use checklist-model the checkbox is not checked and clicking the box never removes nor adds the value to the formData.observations array.

[...html]    
<div class="row">                                    
  <div class="col-md-1 col-sm-1 col-xs-1">                                                   
    <input id="observation" type="checkbox" checklist-model="formData.observations" checklist-value="formData.observations[20]" ng-true-value="[20]" ng-false-value="[]">                                                    
    <label for="smelled_observation"></label>                                                
  </div>                                                 
  <div class="col-md-10 col-md-10 col-xs-10">                                                    
    <label class="filter-label" for="observation">Confirmed</label>                                              
  </div>                                         
</div>

[...service]
formData = {
   version: 1,
   observation: [20],
   actionsTaken: [],
   additionalNotes: 'notes...',
   userName: 'John Doe',
   timestamp: 'ISO8061',
}

When the form loads, the checkbox should be 'checked' because formData.observations = 20 (This worked when using ng-model).




checkbox data not insert in mysql using codeigniter

I try to insert my checkbox data in CodeIgniter. but data did not inserted in the database. here is my view file:

  <input type="checkbox" name="feature[]" value="WIFI" >
  <input type="checkbox" name="feature[]" value="TV">

I am trying to use implode to convert the array into the string, but then I don't how to add in $data array, so they inserted in together

here is my controller:

     public function save()
     {
       $this->load->model('Partner_model');
       $feature = $this->input->post('feature');
      $fea=array(
             'feature'=>json_encode(implode(",",$feature)) 
                   );

      $user_data= array(
     'pname' => $this->input->post('pname'),
     'type' => $this->input->post('type'),
     'address' => $this->input->post('address'),
     'about' => $this->input->post('about'),
     'city' => $this->input->post('city'),
      'code' => $this->input->post('code')
     );
    if($this->Partner_model->save($user_data,$fea))
   {
       $msg = "save sucesss" ;
   }
   else
   {
       $msg = "not save";
   }

   $this->session->set_flashdata('msg', $msg);
   $this->load->view('partner_profile');
 }

& here is my model:

 public function save($data,$fea)
  {
     return $this->db->insert('property', $data,$fea);
  }




C#. Populating DataGridView with data from database. Cant edit any rows, and Read Only is false

So i can't edit any columns in the DGV. Even when i set ReadOnly to 'False'. Some of my columns i don't want the users to edit the data but i want to be able to select the checkbox and i cant :(.. When i was debugging my code any of the columns i have set to ReadOnly = 'True' they are still coming accross as 'False' but i still cant click or edit anything!! Any tips on how to get around this? Spent far to long on this silly problem :(

So i want to just be able to tick the CheckBox, and i cannot do this for some reason.

            sqlConnection.Open();
            MessageBox.Show("Database " + strDatabase + " opened 
            successfully.");

            string sqlSelectCompanies = "SELECT data, moreData,  moreData1, moreData2 " +
                                        "FROM tblClient INNER JOIN tbl ON tbl = tbl WHERE Serverid >=1"); //I cant show all details of the query
            SqlCommand sqlCommand = new SqlCommand(sqlSelectCompanies, sqlConnection);
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
            sqlDataAdapter.Fill(companyDataSet, "Companies");
            dataGridViewCompanies.DataSource = companyDataSet;
            dataGridViewCompanies.DataMember = "Companies";
            dataGridViewCompanies.ReadOnly = true;
            //dataGridViewCompanies.Columns[0].ReadOnly = true;
            //dataGridViewCompanies.Columns[1].ReadOnly = true;
            //dataGridViewCompanies.Columns[2].ReadOnly = true;
            //dataGridViewCompanies.Columns[3].ReadOnly = true;

            //Enabling multiple row selection
            dataGridViewCompanies.MultiSelect = true;
            dataGridViewCompanies.SelectionMode = 
            GridViewSelectionMode.FullRowSelect;

            this.dataGridViewCompanies.AllowSearchRow = true;
            dataGridViewCompanies.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
            dataGridViewCompanies.EnableGrouping = false;

            GridViewCheckBoxColumn gvCheck = new GridViewCheckBoxColumn();
            gvCheck.Name = "Select Company";
            dataGridViewCompanies.MasterTemplate.Columns.Add(gvCheck);
            dataGridViewCompanies.Columns[4].HeaderText = "Select Company";
            //dataGridViewCompanies.MasterTemplate.Columns[4].ReadOnly = false;
            //dataGridViewCompanies.Columns[4].OwnerTemplate.AllowEditRow = true;
            dataGridViewCompanies.Columns[4].ReadOnly = false;




mercredi 19 décembre 2018

Turn CheckBoxes into CheckButtons

I am trying to turn These checkboxes:

enter image description here

Into These Checkboxes(I will refer to these as CheckButtons):

enter image description here

Directly below is the code of the current Check Boxes:

        @foreach (var department in Model.Select(u => new { u.DepartmentId, u.DepartmentName }).Distinct().ToDictionary(u => u.DepartmentId, u => u.DepartmentName).OrderBy(u => u.Value))
    {
        i++;
        <text> &nbsp; &nbsp;</text>
@department.Value <input name="department_chkbox" type="checkbox" value="@department.Key" />
        if (i > 5)
        {
            <text><br></text>
            i = 0;
        }
    }

The HTML of the desired ones is below but it does not tell me much:

<td id="checkboxcontainer">
     <input type="checkbox" name="statusId" value="1" id="ckActive" checked="checked" /><label for="ckActive">Active</label>
     <input type="checkbox" name="statusId" value="2" id="ckLeave" /><label for="ckLeave">Leave</label>
     <input type="checkbox" name="statusId" value="3" id="ckSusp" /><label for="ckSusp">Suspended</label>
     <input type="checkbox" name="statusId" value="4" id="ckTerm" /><label for="ckTerm">Terminated</label>
</td>

Does anyone know what is being called to make the checkboxes turn into "checkbuttons" I wrote the check box code, but I do not have access to the check button code. Im assuming that this is something that is done in eitehr Javascript or Jquery. Also there is no class for the




How does one read checkboxes created in an Angular 6 template

I have some checkboxes being created this way:

        <table>
  <tr class='collectionList' *ngFor="let option of configurationTemplate">
    <td class='formLabel'></td>
    <td>
    <ng-container *ngIf="option.type == 'boolean'">
      <input class='configurationForm' id='id-' type='checkbox' name=""  [checked]="option.value"  [(ngModel)]="option.value"   />
    </ng-container>
    </td>
  </tr>
  </table>

I when I click a button, I fire a method in my controller that does this:

var elements = document.getElementsByClassName('configurationForm');
    var obj = {};
    for(var i=0; i<elements.length; i++) {
      var element = elements[i];
      var name = element.id.replace("id-", "");
      if(element.className.indexOf('dirty')>-1) {
        //console.log(element.id);
        obj[name] = 1;
      } else {
        //console.log(element.id);
        obj[name] = 0;
      }

    }

The problem is that there is no property in the elements I am looping through to tell me whether or not they are checked. So I ended up looking at the className (as you see) -- but this doesn't work when the checkboxes haven't been changed. I just want a checked property to determine whether or not the checkbox is checked, but Angular doesn't seem to provide one. Any ideas what I am doing wrong? This stuff is super easy with plain (no-framework) Javascript.




How to align ng-repeat checkboxes properly

I am trying to show ng-repeat data with properly aligned checkboxes as vertically.Below is the code snippet that i tried:

<table width="100%" class="table">
      <tbody>
        <tr>
            <td><label for="fruits" class="control-label">Select 
            Fruits</label></td></td>
            <td><label ng-repeat="fruit in MainCtrl.fruits">
            <input type="checkbox">  
            </label></td>
        </tr>
        </tbody>
        </table>

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope){
  $scope.fruits = {Apple,Mango};

});

It displays the rows horizontally like below:Apple Mango but i want it to display it vertically.




React Redux - select all checkbox

I have been searching on Google all day to try and find a way to solve my issue. I've created a "product selection page" and I'm trying to add a "select all" checkbox that will select any number of products that are displayed (this will vary depending on the customer). It's coming along and I've got all the checkboxes working but I can't get "select all" to work. Admittedly I'm using some in-house libraries and I think that's what's giving me trouble as I'm unable to find examples that look like what I've done so far. OK, so the code to create my checkboxGroup is here:

    let productSelectionList = (
      <FormGroup className="productInfo">
        <Field
          component={CheckboxGroup}
          name="checkboxField"
          vertical={true}
          choices={this.createProductList()}
          onChange={this.handleCheckboxClick}
          helpText="Select all that apply."
          label="Which accounts should use this new mailing address?"
        />
      </FormGroup>
    );

As you can see, my choices will be created in the createProductList method. That looks like this:

createProductList() {
    const { products } = this.props;
    const selectAllCheckbox = <b>Select All Accounts</b>;
    let productList = [];
    productList.push({ label: selectAllCheckbox, value: "selectAll" });
    if (products && products.length > 0) {
      products.forEach((product, idx) => {
        productList.push({
          label: product.productDescription,
          value: product.displayArrangementId
        });
      });
    }
    return productList;
  }

Also note that here I've also created the "Select All Accounts" entry and then pushed it onto the list with a value of "selectAll". The actual products are then pushed on, each having a label and a value (although only the label is displayed. The end result looks like this: Select Products checkboxes I've managed to isolate the "select all" checkbox with this function:

  handleCheckboxClick(event) {
    // var items = this.state.items.slice();
    if (event.selectAll) {
        this.setState({
          'isSelectAllClicked': true
        });
    } else {
        this.setState({
          'isSelectAllClicked': false
        });
    }
  }

I also created this componentDidUpdate function:

componentDidUpdate(prevProps, prevState) {
  if (this.state.isSelectAllClicked !== prevState.isSelectAllClicked && this.state.isSelectAllClicked){

    console.log("if this ", this.state.isSelectAllClicked);
    console.log("if this ", this.props);
  } else if (this.state.isSelectAllClicked !== prevState.isSelectAllClicked && !this.state.isSelectAllClicked){
    console.log("else this ", this.state.isSelectAllClicked);
    console.log("else this ", this.props);
  }
}

So in the console, I'm able to see that when the "select all" checkbox is clicked, I do get a "True" flag, and unclicking it I get a "False". But now how can I select the remaining boxes (I will admit that I am EXTREMELY new to React/Redux and that I don't have any previous checkboxes experience). In Chrome, I'm able to see my this.props as shown here.. this.props

You can see that this.props.productList.values.checkboxField shows the values of true for the "select all" checkbox as well as for four of the products. But that's because I manually checked off those four products for this test member that has 14 products. How can I get "check all" to select all 14 products? Did I go about this the wrong way? (please tell me that this is still doable) :(




Show/hide dropdown menu if checkbox is checked (multiple) - same class names php

I have an issue with showing/hiding dropdown menus if a checkbox is checked.

If a checkbox is checked, I want to be able to choose the quantity from a dropdown menu (like an e-commerce site). Since I fetch the results the checkboxes and dropdowns have the same name and classname - this is the part where I get confused since I want to use the same jQuery/javascript to show/hide the dropdown menu. At the moment, all dropdowns are not hidden which leads to an error when using $_POST because all dropdowns will be sent as an array but is not matched with the amount of indexes as the checkboxes - therefore I want to disable or display:none on the dropdowns that are not checked ($_POST only works if I click on all checkboxes since it will match with the amount of dropdowns)

Here is the code:

<?php
    include('db_connect.php');

    $sql = "SELECT * FROM Entertainment";
    $result = mysqli_query($conn, $sql);

    if(!$result)
        die(mysqli_error());

    //Fetch array from Entertainment table in DB
    while ($row = mysqli_fetch_array($result)) {
        $seats = $row['seats']; 
        //needed to disable user from choosing more tickets than it exists
        if ($seats <= 0) {
            echo '<input disabled type="checkbox" name="nojen[]" value="' . $row['entId'] . '">' . $row['entName'] . ' - '  . $row['date'] . ' - '  . $row['time'] . ' - '  . $row['seats'] . ' platser kvar <br>';
        }
        else {
            echo '<input type="checkbox" class="nojen" name="nojen[]" value="' . $row['entId'] . '">' . $row['entName'] . ' - '  . $row['date'] . ' - '  . $row['time'] . ' - '  . $row['seats'] . ' platser kvar <br>';
        }
        echo '<select class="antal" name="antal[]">';
            //if there's not enough seats, disable
            for ($x = 1; $x <= 6; $x++) {
                if ($x > $seats) {
                    print "<option disabled value = \"$x\">$x</option>";
                }
                else {
                    print "<option value  = \"$x\">$x</option>";
                }
            }
        echo '</select>';
    }
    ?>

$_POST:

<?php
    include 'db_connect.php';
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    print_r($_POST);

    $firstname = $_POST['fnamn'];
    $lastname = $_POST['enamn'];
    $email = $_POST['email'];
    $phonenumber = $_POST['tel'];
    $tickets = $_POST['antal'];
    $entid = $_POST['nojen'];

    mysqli_query($conn, "INSERT INTO Customer (firstName, lastName, email, phoneNumber) VALUES('$firstname', '$lastname', '$email', '$phonenumber')");

    $customerid = mysqli_insert_id($conn);

    if(!empty($entid)) {
        foreach(array_combine($entid, $tickets) as $entarray => $ticketsarray) {
            mysqli_query($conn, "INSERT INTO Reservation (entId, customerId, tickets) VALUES('$entarray', '$customerid', '$ticketsarray')");
            mysqli_query($conn, "UPDATE Entertainment SET seats = seats - '$ticketsarray' WHERE entId='$entarray'");
        }
    }
    else {
        echo "Error"  . $conn->error;;
    }
echo "Success";
}
    else {
        echo "Error"  . $conn->error;;
    }
mysqli_close($conn);
?>

jQuery:

$(document).ready(function(){
$('[name="nojen[]"]').change(function(){
    if(this.checked)
        $('[name="antal[]"]').fadeIn('slow');
    else
        $('[name="antal[]"]').fadeOut('slow');

});

});

I know that the checked checkbox must know which dropdown it should show or not, but I am unable to figure out why at the moment... Thanks in advance!




problem with while cycle and isset in php

I have this problem with while cycle and isset function: I want that every checkboxes checked rimane checked and those not checked rimane not checked after submit form.

while($dati_query_updte11 = mysql_fetch_array ($query_updte1)){
echo '<input type="checkbox" value="si"';
if(isset($checkk)){echo ' checked ';}else{echo ' ';}
echo 'name="na5file[]">';
}



$checkboxes = isset($_POST['na5file']) ? $_POST['na5file'] : array();   

foreach($checkboxes as $key7 => $value) {
   $checkk = $checkboxes[$key7];   
}

why it doesn't work? thank you in advance...




mardi 18 décembre 2018

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name available as request attribute

Im trying to populate a checkboxes from a list getting from the controller in spring-jsp. Im getting the list from a service and then it is added to the model as an attribute. But im finding it hard to access and display it as checkboxes in the view. So im getting the above error in the log. What could have been gone possibly wrong?

The controller :

    @RequestMapping(value = "/user-roles", method = RequestMethod.GET)
    public String viewRoles(Model model) {

    List<Permission> permissionsList;
    permissionsList = roleService.getAllPermission();

    model.addAttribute("permissions", permissionsList);
    return "user_roles";
}

    @RequestMapping(value = "/roles/addrole", method = RequestMethod.POST)
    public ModelAndView saveEmployee(@ModelAttribute("addrole") SystemRole role, ModelMap model) {

    roleService.saveSystemRole(role);
    model.addAttribute("user", new SystemRole());
    return new ModelAndView("user_roles");
}

the view :

           <div class="modal-body">
            <form:form method="post" modelAttribute="addrole" action="/roles/addrole">
                <div class="form-group">
                    <label for="role-name" class="col-form-label">Role Name</label>
                    <input type="text" class="form-control" id="role-name">
                </div>
                <div class="form-group">
                    <label class="col-form-label">Permissions</label>

                    <div class="check-box" style="padding-left: 20px">
                        <c:forEach items="${permissions}" var="oo">
                            <form:checkbox id="${oo.id}" label="${oo.name}" value="${oo.id}" path="permissionList"/>
                        </c:forEach>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="submit" class="btn btn-primary">Submit</button>
                </div>
            </form:form>
        </div>




can't set values for checkbox attributes in jquery

I have group of checkbox in a table as,

 <input type="checkbox" id1='2' id2="" id3=""/>

gave a default value for id1 and initially value set as empty for id2 and id3. Is this right?? On a button action I am looping all these check boxes as,

                   $("input:checkbox").each(function(){
                         var $this = $(this);

                    });

In this action I have to assign values for id2 and id3(as empty before). I tried many ways, but nothing worked. Can anyone help??




How do you add a label (title text) to a Checkbox in Flutter?

I am playing with Checkbox to see how it works, but I don't see a title option with it.

Checkbox(
  title: Text("Checkbox label"),  // The named parameter 'title' isn't defined.
  value: true,
  onChanged: (newValue) { },
);

Do I have to create my own widget to add a title to it?

This is a Q&A self-answer. My answer is below.




Checkbox Enable/Disable DIV - Localstorage - Onload load the status

I use this checkbox type in my index.html :

<input class="check-1" type="checkbox" value="1" id="check-1"/>

This code in my .js

$(".Categorie.1").show();
$(".check-1").click(function() {
    if($(this).is(":checked")) {
        $(".Categorie.1").hide();
    } else {
        $(".Categorie.1").show();
    }
});

//localstorage
$('input[type="checkbox"]').each(function(){
    $(this).prop('checked', (localStorage.getItem($(this).attr('id')) === 'true') ? 'checked' : '')
});

$('input[type="checkbox"]')  
  .on('change', function() {
    localStorage.setItem($(this).attr('id'), this.checked);
    if (this.checked) {
      $('.' + $(this).data('target')).show();
    } else {
      $('.' + $(this).data('target')).hide();
    }
  })
  .trigger('change');

When i load the page, no problem, the checkboxes that are checked are still ticked. But the DIV appears...

Is there a solution for resolve this ?

Btw, I think the code is quite heavy. Is it possible to make a more compact version?

Big thanks all :-)




CodeBehind Checkbox.Checked = false but boxes remain "visiably" checked, value is false though

I have a list of checkboxes on my asp.net web application that after the submit button is clicked, i am trying to loop threw each checkbox and set its value to false. The checkbox on the page remains with a checkmark still even though its value is false. What event or action needs to happen to make sure the checkbox visually represents its value.

If possible, I'm doing this is c# and I would really like to do this in codeBehind to understand why this is not working.

Thanks for any help




Read Checkboxvalues that were dynamically created in a Datatable c#

I have this code that dynamically created my checkboxes. I have several columns of checkboxes and several rows, so it needs to be totally dynamical.

I don't know how i can read the values of the checkboxes and would like to ask for some help. BTW I would like to save the values in a multidimensional array.

Meldungtable.Columns.Add("Warnungen", typeof(string));

  for (int meldungcnt = 0; meldungcnt < SPSWarnungsBausteinArray.Length; meldungcnt++)
  {
    Meldungtable.Rows.Add(SPSWarnungsBausteinArray[meldungcnt]);
  }
  WarnungenDataGridView.DataSource = Meldungtable;

  for (int kameracnt = 1; kameracnt <= Kameraanzahl; kameracnt++)
  {
    DataGridViewCheckBoxColumn Kamerachk = new DataGridViewCheckBoxColumn();
    Kamerachk.HeaderText = "Kamera" + kameracnt;
    Kamerachk.Name = "KameraChkBox" + kameracnt;
    Kamerachk.Width = 70;
    WarnungenDataGridView.Columns.Add(Kamerachk);
  }

I would read row by row and check for the checkbox name, that i have assigned before, but as I am reading the data in a different method I don't think this works out.

Please help




get parser error in input:checkbox with runat server

i have Parser error. my html code:

   <input id="chk" runat="server" type="checkbox"  name="table_records" <%#Eval("CheckStatus").ToString().Trim() == "True" ? "checked" : string.Empty %>  />

i tried this way:

<%# (bool)Eval("CheckStatus") ? "checked=\"checked\"" : "" %>

but not worked.




Storing a checkbox value in local storage

Im working on a checklist chrome app for myself and would love your help. Basically, I cant figure out how to save a checkbox status. If I check a box and refresh the page, I would like it to stay checked. But I cant seem to code that. Any ideas how to do that? Thank you!!

function get_todos() {
    var todos = new Array;
    var todos_str = localStorage.getItem('todo');
    if (todos_str !== null) {
        todos = JSON.parse(todos_str); 
    }
    return todos;
}
 
function add() {
    var task = document.getElementById('task').value;
 

    var todos = get_todos();
        
    todos.push(task);
    localStorage.setItem('todo', JSON.stringify(todos));
 
    show();
 
    return false;
}
 
function remove() {
    var id = this.getAttribute('id');
    var todos = get_todos();
    todos.splice(id, 1);
    localStorage.setItem('todo', JSON.stringify(todos));
 
    show();
 
    return false;
}
 
function show() {
    var todos = get_todos();
 
    var html = '<ul>';
    for(var i=0; i<todos.length; i++) {
        html += '<li>' + '<input type="checkbox" id="checkbox">' + todos[i] + '<button class="remove" id="' + i  + '">delete</button></li>' ;
    
        
        };
    html += '</ul>';
        
 
    document.getElementById('todos').innerHTML = html;
        
        
        
        
    var buttons = document.getElementsByClassName('remove');
    for (var i=0; i < buttons.length; i++) {
        buttons[i].addEventListener('click', remove);
    };
}



document.getElementById('add').addEventListener('click', add);
show();



Retrieving information of OLEObjects from Workbook with VBA

Scenario: I am trying to read all the information or a worksheet with VBA (initially Python, but I could find no way to do this). Since the sheets I have to read have different formats and are usually a mess, I am looping through all objects in the sheet, getting their name and value (checked or not, as a binary).

Issue: The boxes are usually out of order, so I have no way to know what comes in which order. So I am trying to retrieve some basic form of location or reference to the cells around it.

What I tried: Following the documentation (https://docs.microsoft.com/en-us/office/vba/api/excel.oleobjects) I tried all types of different properties, but none can help with this issue directly. The closest I got was with BottomRightCell, but this only yields the value of the cell, whereas I would need the location or cell number, so I can reference the checkbox properly.

Question: Is there a way to do this kind of identification? Would there be a better way to read all the contents in a sheet (including if a checkbox is checked or not) directly, or those two operations must be done separately?

Code do far:

Sub Test_retrieve()

' this will get all non object values from the sheet

Dim array_test As Variant
Dim i As Long, j As Long

array_test = ThisWorkbook.Sheets(1).UsedRange

For i = 1 To ThisWorkbook.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
    For j = 1 To ThisWorkbook.Sheets(1).Cells(1, Columns.Count).End(xlToLeft).Column
        ThisWorkbook.Sheets(2).Cells(i, j) = array_test(i, j)
    Next j
Next i

End Sub


Sub getavticeboxvalue()

    ' this will get the names and values (as binary) of all the activex controlbox objects in the sheet

    Dim objx As Object
    Dim i As Long

    i = 1

    For Each objx In ThisWorkbook.Sheets(1).OLEObjects

        If objx.Object.Value = True Then
            ThisWorkbook.Sheets(3).Cells(i, 1).Value = 1
            ThisWorkbook.Sheets(3).Cells(i, 2).Value = objx.Name
            ThisWorkbook.Sheets(3).Cells(i, 3).Value = objx.Placement 'here is the issue

        ElseIf objx.Object.Value = False Then
            ThisWorkbook.Sheets(3).Cells(i, 1).Value = 0
            ThisWorkbook.Sheets(3).Cells(i, 2).Value = objx.Name
            ThisWorkbook.Sheets(3).Cells(i, 3).Value = objx.Placement 'here is the issue
        End If
        i = i + 1

    Next objx

End Sub




lundi 17 décembre 2018

Outlook Form - Yes/No event date

I've made a custom form that has several checklist fields (YES/NO) and to them I've associated formula films in order to get the date they are checked. unfortunately the formula fields are not working. Whenever one is checked all the dates are update to the same

What I have: Check1

  • Yes/No field Date1
  • formula (IIf([Check1]=True,Date(),"") Check2
  • Yes/No field Date2
  • formula (IIf([Check2]=True,Date(),"")

and so on

The idea is for the date fields (Formula fields) return the date for each check and not to update all every time an yes/no field is checked

I seem to lack the knowledge to overpass this problem

Can you help?

Thanks!




How can I display the checked boxes of an email form in my email body message?

I'm trying to create a contact us form. I've got a few text input fields, drop down menus, and check boxes. When troubleshooting, I am able to pull the text from the textbox inputs and drop down menus. Unfortunately my code breaks when trying to get the values from my check boxes added to the email body message. How can I include the boxes with the "checked" value in my email body when the form is submitted? Below is an example code. Thank you for the help.

<head>
msg.Subject = "Test Form";
    msg.Body = "\n Name: " + txtname.Text + Environment.NewLine + "\n Color: " + color.Text + Environment.NewLine + "\n Shape " + shape.Value;
</head>    
<body>
<asp:TextBox AlternateText="Name Field" id="txtname" runat="server" 
        MaxLength="32" placeholder="Name" alt="Name*" type="text" > 
        </asp:TextBox>
        <asp:DropDownList id="color" runat="server" AlternateText="Color Field" 
        placeholder="Color" alt="Color Field" type="text" >
              <asp:ListItem Text="Blue" Value="blue" />
              <asp:ListItem Text="Red" Value="red" />
              <asp:ListItem Text="White" Value="white" />
            </asp:DropDownList>
<fieldset>        
        <label for="circle">Circle<input type="checkbox" name="shape" id="circle">
        </label>
        <label for="square">Square<input type="checkbox" name="shape" id="square">
        </label>
        <label for="triangle">Triangle<input type="checkbox" name="shape" id="triangle">
        </label>
</fieldset>
</body>




wpf checkbox custom attribute binding

I am working with WPF application. In which I have a scenario where I have to bind one custom attribute to checkbox. Please check the below code-

<comboBox.ItemTemplate>
   <DataTemplate>
      <checkbox Name="itemCheck" Content = 
         "{Binding Product}">
         cal:Message.Attach ="[Event 
         Checked] = [Action GetProduct()]"
    </checkbox>
  </DataTemplate>
</comboBox.ItemTemplate>

As per the above code I wanted to bind one more attribute with checkbox that will be in use at time of calling "GetProduct" function.

I tried to bind that with "Content" attribute of checkbox but I need another attribute or custom attribute by which I can bind some other property, because Context attribute is in use for showing Headers.

Can we add custom attribute in checkbox or is there any in-build attribute by which I can bind some property?




How change icon checkbox from component p:selectOneRadio primefaces?

I need to change icon checked from component primefaces selectOneRadio, below the component code:

        <p:selectOneRadio value="#{item.listaAtividadesSelecionadas}" 
          rendered="#{item.habilitarItens}"
            layout="grid" columns="1"  >
            <f:selectItems value="#{item.listaAtividades}" />
        </p:selectOneRadio>

I already try to override de CSS primefaces class but I couldn't. Please anyone has a simple solution?




react native text component moving when checkbox is checked

when this checkbox is checked, the adjacent text is moved slightly to the left. Given that the ´position´ property is so limited in react native. How do it stop this from happening?

                       <View style={this.props.checkBoxWrapper}>
                            <CheckBox
                                title={''}
                                checked={this.state.checkedNews}
                                onPress={() => this.setState({ checkedNews: !this.state.checkedNews })}
                                containerStyle={this.props.checkboxContainerStyle}
                                checkedColor='white'
                            />
                            <Text style={this.props.checkBoxTextStyle}>{I18n.t(this.props.labels.checkBoxNewsDialog)}</Text>
                        </View>




Dealing with checkboxes with jade and mongoose

I am struggling with this simple checkbox in form. I want to update the vehicle value (as an array of numbers) in the user schema when this form is submitted. When I put the variable as a value of an invisible input document.getElementById("vals").value = vals; the array is stored as one block of string in the database and when I call [vals] directly in node then it's updated to nothing. I would really appreciate it if you tell me what I am doing wrong.

my jade code:

form.form(action='/volDetails', method='POST')
  .form-group
    input(type='checkbox', value='1', name= 'vehicle[type]')
    label(for='vehicle[type]')
    | Car
    input(type='checkbox', value='2', name= 'vehicle[type]')
    label(for='vehicle[type]')
    | Van 
    input(type='checkbox', value='3', name= 'vehicle[type]')
    label(for='vehicle[type]')
    | Bike 
    input(type='checkbox', value='4', name= 'vehicle[type]')
    label(for='vehicle[type]')
    | bus
    input(type='checkbox', value='5', name= 'vehicle[type]')
    label(for='vehicle[type]')
    | disabled 
script.
   var vals = [];
   $(document).ready(function () {
       var $checkes = $('input:checkbox[name="vehicle[type]"]').change(function () {
           vals = $checkes.filter(':checked').map(function () {
               return parseInt(this.value);
           }).toArray();
       });
   }); 

my node code:

app.post('/volDetails', function(req, res) {
  var conditions = mongoose.model('User').findOne({
            userId: req.user.userId
        }, function(err, doc) {
            doc.vehicle = req.body.vals;
            doc.save(function(err) {
                res.redirect('/');
            });
        }
    );
})




Codename one - checkbox option in overflow menu

I have a form with a basic overflow menu, that is supposed to offer options of manipulating a list of items of that form. One part is sorting the list by various means (which works well), the other part is providing a filtering of the list. E.g. having a simple shopping list of items that can be checked and I want the filter to show only "open" items, yet unchecked to focus on.

Can I add a previously assembled component to the overflow menu? Its just a dialog spawning in that location, so it should be able to house any component for that matter. However, the options "add(Material)CommandToOverflowMenu" only allow to add commands directly or a string, icon, listener combination.

If a custom component is not possible, I could still use the icon to show an empty checkbox first, and then update to an checked checkbox icon, once pressed. However, how to manipulate an existing overflow item, after it was added? I dont even see a way to remove previously added overflow items, as the "getOverflowCommands" returns an Iterable, which is not supposed to be used for manipulation of the list.

Is there a way to do this, I do I have to setup my own, custom, overflow menu like dialog?

Thanks and best regards




dimanche 16 décembre 2018

How to set one checkbox instance of component to false, when another instance is set to true?

How can I create a checkbox component in vue.js, lets say (HTML representation):

<v-switch></v-switch>
<v-switch></v-switch>

So when I create two checkboxes like this I want to change the other one to false if the first one is set to true, and and vice versa. Also they both can be false at the same time.

(I am new with vue.js,I just want to add this in a existing environment).

Code that exists

    Vue.component('v-switch', {
    props: ['value', 'disabled', 'color'],
    template: `
        <div class="switch">
            <label>
                <input type="checkbox" :disabled="disabled" @change="emitChange()" v-model="data">
                <span class="lever" :class="color_class"></span>
            </label>
        </div>`,
    data: function () {
        return {
            data: this.value || '',
            color_class: 'switch-col-' + (this.color || 'green')
        };
    },
    methods: {
        emitChange: function () {
            var vm = this;
            setTimeout(function () {
                vm.$emit('change', vm.data);
            });
        }
    },
    watch: {
        data: function () {
            this.$emit('input', this.data);
        },
        value: function () {
            this.data = this.value;
        }
    },
    mounted: function () {
        //this.data = this.value;
    }
});

and the HTML:

 <v-input-wrap translate="newsletter" class="col-sm-1 col-12">
 <v-switch v-model="contact_persons[index].newsletter"></v-switch>
 </v-input-wrap>
<v-input-wrap translate="blacklist" class="col-sm-1 col-12">
 <v-switch v-model="contact_persons[index].blacklist"></v-switch>
 </v-input-wrap>




Custom CSS Checkbox with pseudo element not selectable, not working

I have a question on how do make a custom css checkbox in a contact form work. After some research I went with the suggested approach to use a ::before and ::after pseudo class on my label-element. With hover and so on, and it looked okay.

But once I want to select a checkbox and click on it, the after-state of the checkbox disappears and it seems like nothing was selected.

I searched a lot but didn't find the right solution yet. Hopefully someone can help me out.

Thank you in advance!

Here is my jsfiddle: https://jsfiddle.net/trsxj0o2/

Here the HTML:
<!Doctype html> ...Complete Code is in the jsfiddle. 

Note: Yes, I know the white background isn't fitting, don't let that distract you ;-) Besides I am new to stackoverflow and the jsfiddle, so if it isn't working please let me know.




samedi 15 décembre 2018

AJAX success alert is not activating even with HTTP code: 200

Here is the checkbox that I target:

 $query = " SELECT DISTINCT(collection) FROM products";

            $featured = mysqli_query($conn,$query);
                    while ($row = mysqli_fetch_assoc($featured)){?>

                    <div class="list-group-item checkbox" style="background- 
                    color: #f4f4f4;">

                        <label><input type="checkbox" class="common_selector 
                        collection" style="" value="<?php echo 
                        $row['collection']; ?>" id='<?=$row["collection"];? 
                        >'><?php echo $row['collection'];?></label>
                   </div>
                   <?php } ?>

Here is the AJAX:

$("input:checkbox").change(function(){
            var product_collection = $(this).attr('id');    
            var action = "coll";
            console.log(product_id);


            $.ajax({
                url:"../PHP_Scripts/fetch_data.php",
                method: "POST",
                dataType: "json",
                data:{
                    product_collection:product_collection,  action:action
                },
                success:function(){
                     alert("hello");

                }
            });


      });

And here is fetch_data.php

header("Location: page_2.php");   

As you can see, I just want it to redirect to a different page. The success does not send and I can't find what is wrong with the code.

The network tab shows that the data does get sent with a code of: 200 and it does contain the data that needs to be sent. Any ideas?




How to check if checkbox is checked in c# [duplicate]

This question already has an answer here:

I'm trying to show a Message box on button clicked for the Checked Checkboxes in Datagridview

Here is my code:

private void btnSave_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < PayingDG.Rows.Count; i++)
        {
            if (PayingDG.Rows[i].Cells[4].Value.ToString() == "yes")//this is the checkbox column 
            {
                MessageBox.Show(i.ToString());
            }
        }
    }

It gives the following error:

Object reference not set to an instance of an object.

Any suggestions?




vendredi 14 décembre 2018

ASP.Net MVC checkbox using prettycheckable keeps checking after validation fails and returns to view

I'm not sure if this is standard behavior but I have a checkboxfor in my form and I'm using the prettycheckable JS lib to style it. When I post to the server and the model state is invalid and I return to the page, the checkbox is still checked!

I try to set the models property bool value to false in the action, but I still have it checked when the page returns. I also tried setting 'checked = false' in the element but that didn't do anything either.

Is this what I should expect? I would like to reset it and have it unchecked if the model state fails and I have to return to the page.

Here is the checkbox

@Html.CheckBoxFor(m => m.AgreeToTerms, new { @id = "AgreeToTerms", data_label = "Agree To Terms", @checked = false })

Here is the viewmodel

public bool AgreeToTerms { get; set; }

in my action here I try and set the checkbox to false if the model state fails

    [HttpPost]
    public ActionResult SomeAction(SomeViewModel viewModel)
    {
        if (!ModelState.IsValid)
        {
            viewModel.AgreeToTerms = false;
            return View("SomeView", viewModel);
        }
    } 




Is there are any way to make checkbox like radio button?

Html question. When I use the radio button with gender, then I can select only one button. But when I do the same things with the checkbox, it allows me to select multiple buttons. Is there are any way to make checkbox like radio button?

<head>
    <title>non breaking space</title>
</head>

<body>

    <input type="radio" name="gndr">Male 
    <input type="radio" name="gndr">Female
    <!--!!!!!!!!!!?-->
    <input type="checkbox" name="gndr">Male 
    <input type="checkbox" name="gndr">FeMale

</body>




Checkbox with value from user input

I have some checkboxes people need to fill in, but I want 1 checkbox to be so users can make their own input.

My question is: How can I get the user to fill in their own input so I can store it in my database?