vendredi 30 juin 2017

How to make a checkable 3D model and return its data

I have embeded a 3d hours model at website and how can I make it checkable on certain part like kitchen, restroom etc and return its data to tell me which is checked

I don't understand how to set data on the model and how to receieve it through javascript(?).

The 3D model is made by SketchUp and embeded with three.js.




Declared CheckBox Showing up as Undeclared in Validator

I'm getting an error saying that CheckBox1 is not declared, but it definitely is, earlier in the gridview. The background is that users are approving records in a gridview. If the record is not approved, the checkbox is unchecked. Because it was not approved, I would also like to require a comment from the user explaining why. The comment is only required if the checkbox is unchecked.

I've tried shifting the validators around, but I'm not having any luck. Is there something I'm missing? Still pretty new to asp.net. Back end is vb.net. Below is the comment field. If more is required, just let me know.

The Error:

'CheckBox1' is not declared. It may be inaccessible due to its protection level.

The Code:

<asp:TemplateField HeaderText="Comment">
    <ItemTemplate>
        <asp:TextBox ID="Comment" MaxLength="200" runat="server" Width="500px" Text='<%# Eval("Comment") %>'></asp:TextBox>
        <asp:RegularExpressionValidator 
            Display = "Dynamic" 
            ControlToValidate = "Comment" 
            ID="RegularExpressionValidator" 
            ValidationExpression = "^[a-zA-Z0-9'@&#.\s]{2,200}$"
            runat="server"  
            ForeColor="red" 
            ErrorMessage="!">
        </asp:RegularExpressionValidator>
        <%If CheckBox1.Checked = "False" then%>
            <asp:RequiredFieldValidator id="RequiredFieldValidator" runat="server"
                ControlToValidate="Comment"
                ErrorMessage="*Required"
                ForeColor="Red">
            </asp:RequiredFieldValidator>
        <%Else%>
        <%End If%>
    </ItemTemplate>
</asp:TemplateField>




Remove Duplicates from String in Cell

So, I've been wrestling with this problem a while. Anytime CheckBox3 and CheckBox6 are both checked, it duplicates the "-", when I just need one. I've tried to use Len, as well as a array to go through the string to delete duplicates, but neither did the trick for me; I'm probably just doing it wrong, since I'm still a beginner with VBA. Anyway, here's my code:

Private Sub btnOK_Click()
Dim strText As String, strDelimiter As String

strDelimiter = " "

If cbxDD.Value = "DD" Or cbxMM.Value = "MM" Then
    MsgBox "Please enter both a month and date.", , "Invalid Entry"
    Exit Sub
End If

If CheckBox4.Value = True Then strText = strText & "DR" & strDelimiter
If CheckBox5.Value = True Then strText = strText & "C" & strDelimiter
If CheckBox2.Value = True Then strText = strText
If CheckBox1.Value = True Then strText = strText & ChrW(8730) & strDelimiter
If CheckBox3.Value = True Then strText = strText & "-" & strDelimiter
If CheckBox6.Value = True Then strText = strText & "- CP" & strDelimiter
If CheckBox7.Value = True Then strText = strText & "Cancelled" & strDelimiter
If CheckBox9.Value = True Then strText = strText & "TS21" & strDelimiter
If CheckBox8.Value = True Then strText = strText & "Lost" & strDelimiter

If Len(strText) > 0 = True Then
    strText = Left(strText, Len(strText) - Len(strDelimiter)) 'remove trailing delimiter
    ActiveCell.Value = cbxMM.Value & "/" & cbxDD.Value & " " & txtCode.Value & " " & strText
    Unload Me
Else
    MsgBox "No Status selected.", , "Invalid Entry"
End If

If CheckBox2.Value Or CheckBox4.Value Or CheckBox5.Value = True Then
    ActiveCell.Value = "x" & ActiveCell.Value
Else
    ActiveCell.Value = ActiveCell.Value
End If    
End Sub

Any help would be great! Thanks.




Checkbox doesn't work properly in selenium

Below steps I need to do:

  1. check if the checkbox is ticked or not.

a)If it is ticked then follow certain steps

b)If it is not ticked then tick the check box and follow the same steps in a)

This is my HTML code:

<td style="width: 4.5%; padding-left: 2px;" class="heading" data-bind="css: selected() ? 'headingSelected' : 'heading'">
                            <img title="Click to show all employees" data-bind="click: _apps.expandUnExpand, visible: !expanded()" class="clickable" src="/Content/Images/plus.gif" style="display: none;">
                            <img title="Click to hide all employees" data-bind="click: _apps.expandUnExpand, visible: expanded()" class="clickable" src="/Content/Images/minus.png">
                            <img title="Click To Select Application" data-bind="click: _apps.selectUnSelect, visible: !selected() &amp;&amp; !_apps.readOnly() " class="clickable" src="/Content/Images/unchecked.png">
                            <img title="Click To Unselect Application" data-bind="click: _apps.selectUnSelect, visible: selected() &amp;&amp; !_apps.readOnly() " class="clickable" src="/Content/Images/checked.png" style="display: none;">

                        </td>

Below is my code:

if(driver.findElement(By.xpath("//[@id='AuraACLs']/div[2]/div[1]/table/tbody/tr/td[1]/img[3]")).isEnabled()) //Xpath when checbox is ticked

{

System.out.println("checkbox is selected");

driver.findElement(By.xpath("//button[text()='Add to ACL']")).click();

}

else  
if(driver.findElement(By.xpath("//[@id='AuraACLs']/div[2]/div[1]/table/tbody/tr/td[1]/img[3]")).isEnabled()) //xpath when checkbox is not ticked
                    {

System.out.println("checkbox is unselected");

driver.findElement(By.xpath("//[@id='AuraACLs']/div[2]/div[1]/table/tbody/tr/td[1]/img[3]")).click();// tick the checkbox

driver.findElement(By.xpath("//button[text()='Add to ACL']")).click();  

}

If I try with single if the code works but when I combine both the If(if and else if) code dosn't work




custom listview checkbox and edit box loss data when scroll down

hello every one i am new to android i have custom Listview with edittext and check box when i check the box and enter data in edittext and scroll the listview and return back to that box its change its state to previous state means unchecked and edittext box data lost public

View getView(final int position, View arg1, ViewGroup viewGroup) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row = inflater.inflate(R.layout.stocklistcustom, viewGroup, false);
        final CheckBox checkbox1 = (CheckBox) row.findViewById(R.id.checkbox1);
        TextView Des = (TextView) row.findViewById(R.id.description);
        final TextView stockid = (TextView) row.findViewById(R.id.stockid);
        final EditText done = (EditText) row.findViewById(R.id.quantity);

        stockid.setText(listItem.get(position));
        Des.setText(listAddress.get(position));
        done.setText(quantity.get(position));

        checkbox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                int i=0;
                if (checkbox1.isChecked()){

                    String id,qu,des,stc;
                    id=idlist.get(position);
                    qu=quantity.get(position);
                    des=listAddress.get(position);
                    stc=listItem.get(position);

                    ItemID_list.add(i,id);
                    StockCode_list.add(i,stc);
                    Description_list.add(des);
                    Quantity_list.add(i,done.getText().toString());



                }

                else {

                    ItemID_list.remove(i);
                    StockCode_list.remove(i);
                    Description_list.remove(i);
                    Quantity_list.remove(i);
                    i--;
                }
            }
        });

        //date.setText(dates);



        return row;
    }

this is my getview function if any body can solve this problem please




How to invoke reactjs function in a dynamic checkbox creation

I'm looping an object in reactjs and want to create checkboxes based on the object contents, associated with each checkbox an onChange event and i want to invoke a function there, what's the proper way to link my function with the event ?

 Object.keys(obj).map((i, item) => 
{
           $("#main").append("<input type='checkbox' value="+obj[i].Value+" 
           id="+obj[i].ID+" onChange="+{this.load.bind(this,obj[i].ID)}+" />");
});

this is where i get the binding error Thanks in advance.




How to create a checkbox for multiple choice on PHP

I have an input field I changed it to a checkbox for multiple choices. The worry here I can't add the checkbox, I mean that my user should click on Ctrl and select on the same time several choices. You can see it in this Image:

enter image description here

This following my code of the form:

$app->get('/Chart/{currency}/{year}/{zone}/{lru}....... , function(Request $request,...... $repsite, $lru, $contract, $forecast) use ($app) {
if ($app['security']->isGranted('ROLE_USER')) {
    ///start form 
    $user = $app['security']->getToken()->getUser();        
    $form = $app['form.factory']->createBuilder('form')->setMethod('GET')
    .
    .
    .
    .
 ->add('lru', 'choice', array(
                    'choices' => array(                 

                    '\'ATSU\'' => 'ATSU',
                    '\'APCC\'' => 'APCC',
                       .....
                     ),

                    'required' => FALSE,
                    'empty_value' => 'ALL',
                    'empty_data' => NULL,
                    'multiple' => TRUE                      
                    //'expanded' => TRUE
                ))

I want do a classic checkbox like this on the right:

enter image description here

I did a research on forums I found that I should use multiple and expanded and to set them to TRUE. When I add expanded=TRUE list became very "ugly", I give you a screensheet:

enter image description here

Can you please tell me how can I change my code to do a checkbox for multiple choicelike in the picture above. I hope that I find solution. Thank you.




Set custom image to checkbox without mandatory label

I have a project where sometimes checkboxes don't have labels.

Are there any CSS way (at least hacky) to set custom image to checkbox without changing markup? input[type="checkbox"]:before works only in Chrome.




jeudi 29 juin 2017

When progmatically adding elements through a loop, only the first one appears (C#)

I have a list of user defined "tags" stored in a list of strings called warehouse.tags. Using a basic for loop, I am creating checkboxes for each of the tags and adding them to a panel within a windows form.

The problem is that only the first checkbox shows up. I stepped through the code several times, and the location coordinates and other properties seem to be working. The problem does not seem to be that the checkbox location is outside the panel boundaries.

   for(int i = 0; i < warehouse.tags.Count; i++) //adds check boxes for each tag
        {
            CheckBox tagNameLabel = new CheckBox();
            tagNameLabel.Text = warehouse.tags.ElementAt(i);
            Point tagLabelPoint = new Point();
            tagLabelPoint.X = xAdjuster; // xadjuster = 25 in this case 
            tagLabelPoint.Y = (5 + yAdjuster) * (warehouse.categories.Count + 1); //yadjuster = 25 as well
            tagNameLabel.Location = tagLabelPoint;
            this.filterOptionsPanel.Controls.Add(tagNameLabel);

        }

Open to any ideas of what may be going wrong - thanks.




reactjs checkboxlist component - Updating state changes in parent

I have a bunch of checkbox-list requirements. I will explain in detail. I have a bunch of languages say:

var languages = ["English", "German", "French", "Spanish", "Mandarin", "Tamil"]

I have a parent component which has a form where I have four sections, Say:

class Page extends React.Component {
  render() {
    return (
      <form>
        <h1>CanSpeak</h1> <chkboxlist someProp="speak" />
        <h1>CanSpeak</h1> <chkboxlist someProp="read" />
        <h1>CanSpeak</h1> <chkboxlist someProp="write" />
        <h1>CanSpeak</h1> <chkboxlist someProp="understand" />
        <button
          onClick={e => {
            console.log("Need the various chkboxlist values here");
            e.preventDefault();
          }}
        >
          Save
        </button>
      </form>
    );
  }
}

I want the chkboxlist component to keep track of the list of selected languages in each section and make them available in the "Save" button click handler. I wish to keep track of the state changes (list of selected languages under each section) in the "Page" component.

I do not want to use redux or some such external state management.

Now what is the way to create this chkboxlist component such that the state changes can be tracked in the parent Page component ? Are there any existing components which will fit this requirement and is used widely in the react ecosystem without having to reinvent the wheel ?




In a matlab gui pressing spacebar (un)checks a checkbox if it is focused. How can I turn this behaviour off?

I have a matlab gui made with guide that has a checkbox uicontroll. When that checkbox is focused, pressing spacebar (un)checks that checkbox. I don't want this behaviour - how can I turn this off?

I want to turn it off because I have defined a keypressFcn for the spacebar and I want something else to happen when the user presses the spacebar. atm that 'something else' is working. If spacebar is hit, my keypressFcn runs and does what it should do and additionally the checkbox (un)checks. I only want it to execute my keypressFcn, though..

I don't really know where to start solving this problem.. Just some generall direction instructions would already be helpfull!




Windows Form DataGridView Checkbox value Always True When Checked/Unchecked

We have a Windows form application that has a DataGridView control containing a column with a checkbox in it.

enter image description here

When a user checks or unchecks the box in the row/cell in the DataGridView, we'd like to get the updated value (true or false).

The problem is, the value is always evaluated to true when using our current code implementation.

 private void gvDocumentContents_CellContentClick(object sender, DataGridViewCellEventArgs e)
    {
        if (e.ColumnIndex == 6)
        {
            DataGridViewRow dgvr = gvDocumentContents.Rows[e.RowIndex];
            DataGridViewCheckBoxCell cbCell = dgvr.Cells[6] as DataGridViewCheckBoxCell;
            MessageBox.Show(cbCell.Value.ToString());
        }
    }

I've seen similar issues regarding this topic, however after spending the better part of the day looking, I haven't had much success with some of the other solutions that we tried.

Thanks




Radio input with surrounded by anchor tag doest work

I writing an app in AngularJS2, and I have a simple navigation bar on the top. The user is supposed to click on navigation and page jump to sections. Navigation has inline anchor tags with input radio buttons in them.

<label for="yp">
     <a href="test.com" target="_blank"><input type="radio" id="yp">This is a radio bitton</a>
</label>

The problem is sometimes anchor tag works, and radio input doesn't, and sometimes radio input works and the anchor doesn't.

How can I resolve it preferably without JS/AngularJS2?




initialize the CheckBox with Month and year? [duplicate]

This question already has an answer here:

I try to initialize my JCheckBoxes(month and year) with month = monthname and the year.

So the difficult part is that I must use "Calender".class and "GregorianCalendar".class .

My dont explain it to much. He just said that if the programm start at the first time it should have the current date selected another difficulty.

I really try to read the javadoc but I dont understand them if I am honest.

I know there is a Method for the class "Local Date" called now() but this method does not exist on the both class I must use.

Calendar calendar = Calendar.getInstance();
GregorianCalendar gregorianCalendar = new GregorianCalendar();

    JPanel panel = new JPanel(new FlowLayout());
    panel.add(new JLabel("Please choose"));
    panel.add(new JLabel("Month:"));
    panel.add(new JLabel("Year:"));
    panel.add(new JComboBox(new String[]{"String1", "String2"}));
    panel.add(new JComboBox(new String[]{"String1", "String2"}));

    ImageIcon imageIcon = new ImageIcon("");
    panel.add(new JLabel(imageIcon));

    return panel;

I hope you guys can help and I know I dont give you much information and I am feeling really bad. But you can give me also a little hint.

Best Regards

Josh




Android - View, Checkboxes, TextViews not refreshing at Runtime

I'm new to Android, and I'm having a problem with checkboxes and textviews not refreshing at runtime. The TextView has to change color from light gray to a lighter gray, and the Checkbox has to change the custom drawable that it has from red to green. I have tried the detach and attach the fragment but it shuts down and maybe I don't know where to put the detach and attach in the fragment. I have tried invalidate() and requestLayout(), and it shuts down there too. I tried having them in onCreateView() and maybe I shouldn't put them there. I don't have an activity with my fragment. Here are the images that I need to change. What it has in the preview window is the green custom checkbox drawables but at runtime they are the red custom drawables which is what they were before I changed them to green, and the TextViews are a lighter gray in the preview window but they are a darker gray at Runtime which is what they were before.

Green checkbox custom drawable Red custom custom drawable

           <CheckBox
            android:id="@+id/chkStarted"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/start"
            android:layout_below="@+id/chkInProgess"
            android:gravity="top"
            android:padding="4dp"
            android:checked="true"
            android:enabled="false"
            android:layout_marginTop="10dp"
            android:button="@xml/custom_checkbox_green"/>

        <CheckBox
            android:id="@+id/chkDownloaded"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_below="@+id/chkStarted"
            android:text="@string/download"
            android:gravity="top"
            android:padding="4dp"
            android:checked="true"
            android:enabled="false"
            android:button="@xml/custom_checkbox_green"/>

The textviews are not changing colors either at runtime, and I have tried to refresh the layouts, but they're not refreshing at runtime. They are what they need to be in the preview window, but they are not what they're supposed to be at runtime. Any help would be much appreciated. Thanks in advance!




Change in the model doesn't affect the DOM Checkbox AngularJS

I am using a checkbox binded to a $scope variable in AngularJS. My code is something like:

<input type="checkbox" ng-model="value.selected"> and I have an object in my controller $scope.value which has the selected property. The changes in the DOM i.e. clicking the checkbox changes the values of the selected property in the value object but the vice versa, i.e. if I change the selected property in the controller it doesn't change the DOM checkbox. Any suggestions or workarounds would be welcome.




How to avoid checkbox being selected when clicking on table row

I have a table with one of the columns a checkbox that I need to activate or not depending on a certain logic.

My problem is even when the checkbox is deactivated, when I click away from the checkbox, at the table row, the checkbox get selected.

What is best approach to fix this? Make the row tables deactivated too?

 <table st-safe-src="sampleOverview.dataSet" st-table="sampleOverview.displayed" class="table table-striped">
    <tr ng-repeat="sample in sampleOverview.displayed track by $index" ng-click="sample.selected = !sample.selected" ng-class="{success: sample.selected, warning : sample.deviceId == null || sample.methodId == null }" ng-disabled="sample.deviceId == null || sample.methodId == null">
                <td class="hidden-xs hidden-sm"></td>
                <td class="hidden-xs hidden-sm"></td>
                <td></td>
                <td></td>
                <td></td>
                <td class="text-center hidden-xs hidden-sm">
                    <input type="checkbox" ng-model="sample.selected" ng-click="sampleOverview.selectSample($event, sample)" ng-disabled="sample.deviceId == null || sample.methodId == null">
                </td>
            </tr>
        </tbody>
    </table>

enter image description here




Functions for disabling checkboxes not working corrently

The functionality is: When 1 of the checkboxes is checked, the other must be disabled. It's working, but after updating the WordPress page and trying to edit the checkbox, i got the following problem: enter image description here

First i've checked the Display Excerpt, then updated the page and as you can see, there are 2 boxes which are checked

Checkboxes"

<div><input type="checkbox" id="dx_article_excerpt" onclick="disableContentCheckbox()"><label for="dx_article_excerpt"><?php _e( 'Display Excerpt', 'dxeasypb' ); ?></label></div>
<div><input type="checkbox" id="dx_article_content" onclick="disableExcerptCheckbox()"><label for="dx_article_content"><?php _e( 'Display Content', 'dxeasypb' ); ?></label></div>

And here're the functions:

function disableContentCheckbox(){
            if (document.getElementById('dx_article_excerpt').checked) {
                document.getElementById("dx_article_content").disabled = true;
            } else {
                document.getElementById("dx_article_content").disabled = false;
            }
        }
        function disableExcerptCheckbox(){
            if (document.getElementById('dx_article_content').checked) {
                document.getElementById("dx_article_excerpt").disabled = true;
            } else {
                document.getElementById("dx_article_excerpt").disabled = false;
            }
        }

Why is this happening ?




Disabling checkboxes not working correctly

I want to disable 1 box after checking other. Look at the video: http://ift.tt/2sq2fPf

But you can see that there's a little bug: Here's my code:

function disableContentCheckbox(){
            if (document.getElementById('dx_article_excerpt').checked) {
                document.getElementById("dx_article_content").disabled = true;
            } else {
                document.getElementById("dx_article_content").disabled = false;
            }
        }
        function disableExcerptCheckbox(){
            if (document.getElementById('dx_article_content').checked) {
                document.getElementById("dx_article_excerpt").disabled = true;
            } else {
                document.getElementById("dx_article_excerpt").disabled = false;
            }
        }

Why this happens ?




bootgrid checkbox rowSelection is not working

I just want to repost a Question which was asked:

Bootgrid select row when checkbox is clicked

I have the same problem now and there was still no answer. Is there anyone who knows how to fix the bug?




"Never ask again" feature on Electron dialog.showMessageBox method

I have a dialog.showMessageBox that works well and do what I tell it to do.

electron.dialog.showMessageBox({
            type: 'info',
            buttons: ['Yes', 'No'],
            message: 'Are you sure?',
        }, resp => {
            if (resp === 0) {
                // User selected 'Yes'
                foo.bar();
            }
        });

But it's annoying to answer each times this function is called, I'd like to insert a "Never ask again" like this.

electron.dialog.showMessageBox({
            type: 'info',
            buttons: ['Yes', 'No'],
            message: 'Are you sure?',
            checkboxLabel: 'Never ask me again',
            checkboxChecked: false
        }, resp => {
            if (resp === 0) {
                // User selected send
                foo.bar();
            }
        });

Dialog box

The documentation says that the boolean checkboxChecked can be used in the callback function but I'd like to know how to make it global so that the question isn't ask anymore.




how to add checked items to a different array from unchecked items? angularjs

I'm trying to create a button that would delete all complete items in a to do list --- after trying several different ways to accomplish this, I figure its probably easiest to just send checked items to one array, and unchecked items to another array, so I can make a button that just clears the checked items array... but nothing I am doing is working... thoughts?

html:

<input type="text" placeholder="To do..." ng-model="vm.myTask">
<button type="button" ng-click="vm.submitTask()">Submit</button>
<br>

<div ng-repeat="task in vm.myTasks" ng-class"'checkedbackground': task.checked">
<ul><li><input type="checkbox" value="" ng-model="task.checked">  <button type="button" ng-click="vm.myTasks.splice($index, 1)">Delete</button> </li>
</ul>
</div>

<button type="button" ng-click="vm.clearAll()"> Clear Complete</button>

homeController.js

var myTasks = [];
var completeTasks [];

class HomeController {



//submit task from input value
submitTask(){
//push new task into array
  myTasks.push({name: this.myTask, checked: false});

}
constructor(myTask, checkedTask){
this.myTasks = myTasks;

}

clearAll(){



}

}



angular.module("myapp").controller("HomeController", HomeController);

I erased what I tried but some of what I tried involved this:

constructor(myTask, checkedTask){
    this.myTasks = myTasks;
    completeTasks.push({name: this.checkedTask, checked: true});
    }

that broke the whole thing though.




change color of databound gridview checkboxes depending on their bool value - either checked or unchecked (true/false)

I have a gridview in asp.net web form. It is bound to a database and I have a column where the data type is bit. This has automatically changed the bound field to checkboxes. I like the checkboxes but would like to conditionally format the cell they are in based on whether they are checked or not.

 protected void allgv_RowDataBound(object sender, GridViewRowEventArgs e)
    {


        if (((CheckBox)e.Row.Cells[4].Controls[0]).Checked == true)


        {
            e.Row.Cells[4].ControlStyle.BackColor = System.Drawing.Color.Red;
        }


    }

The above code throws an exception of "Object reference not set to an instance of an object."

I feel like I'm on the right lines but just need a little help.

Here is the HTML if it helps:

   <asp:GridView ID="allgv" runat="server" AutoGenerateColumns="False" CellPadding="5" CellSpacing="1" DataSourceID="SqlDataSource5" Font-Names="Raleway" ForeColor="White" Width="100%" OnRowDataBound="allgv_RowDataBound">
    <Columns>
        <asp:BoundField DataField="Competitor" HeaderText="Name" SortExpression="Competitor" />
        <asp:BoundField DataField="Detail" HeaderText="Detail" SortExpression="Detail" />
        <asp:BoundField DataField="Decision" HeaderText="Decision" SortExpression="Decision" />
        <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
        <asp:checkboxfield DataField="checkboxfield1" HeaderText="checkboxfield1" SortExpression="checkboxfield1"  />
            <asp:checkboxfield DataField="checkboxfield2" HeaderText="checkboxfield2" SortExpression="checkboxfield2" />
            <asp:checkboxfield DataField="checkboxfield3" HeaderText="checkboxfield3" SortExpression="checkboxfield3" />
            <asp:checkboxfield DataField="checkboxfield4" HeaderText="checkboxfield4" SortExpression="checkboxfield4" />
            <asp:checkboxfield DataField="Other" HeaderText="Other" SortExpression="Other" />
    </Columns>
</asp:GridView>




mercredi 28 juin 2017

How to disabling checkboxes inside recyclerview android

I have list/rows of checkboxes inside recylerview. In my case user can only select 3 checkboxes out of many. As soon as user selects the third checkbox, I want to disable rest of the checkboxes in different rows.

I am capturing selecting/deselecting checkboxes inside adapter class.

As far as I know, I can enable/disable checkboxes inside onBindViewHolder class.

But in my case I want to enable/disable checkboxes, after they have been rendered.

One of the approach I can think is, to call notifyDataSetChanged(); from Activity class and then rerender all the recyclerview.

But I hope there is better way than doing this, inside the adapter class itself.

ps: I am new to android/java.




Excel Macro CheckBox How to Clear when Unchecked

I have a simple problem I cannot figure out:

I have a list of ~15 checkboxes in a spreadsheet

I would like to have the timestamp posted in the cell next to the checkbox when I "check" it, and when I "uncheck" I would like to clear the adjacent cell.

Any help would be greatly appreciated, Thanks.




if statement using jquery selectors and checkboxes

I have a form with two text input fields and a series of checkboxes.

There is a variable fields which stores some arrays with data pertaining to the selected fields. I have hardcoded the values into the script with no problem but I cannot seem to find out how to properly compose an if statement to check the status of the checkboxes and only use those values, rather than hardcoding the selected fields.

var start, end, fields;

$(function() {
  $("#form1").submit(function(event) {
    var endD = $("#endDate").val();
    end = endD;
    var startD = $("#startDate").val();
    start = startD;

    //fields = ['PM1','PM2.5','PM10'];


    //if $("#PM1").is("checked"))){
    //fields = ["PM1"];
    //}


    if ($("PM1").attr("checked")) {
      fields = ["PM1"];
    }


    event.preventDefault();

    build_graph();
  });
});
<script src="http://ift.tt/1oMJErh"></script>
<form id="form1">
  Start Datetime:<br>
  <input type="text" name="startDate" id="startDate" class="Date" placeholder="YYYYMMDD-HHMM"><br> End Datetime <br>
  <input type="text" name="startDate" id="endDate" class="Date" placeholder="YYYYMMDD-HHMM"><br> Parameter
  <br>
  <input type="checkbox" class="parameter" id="PM1">PM1<br>
  <input type="checkbox" class="parameter" id="PM2.5" checked>PM2.5<br>
  <input type="checkbox" class="parameter" id="PM10">PM10<br>
  <input type="checkbox" class="parameter" id="Temp">Temperature<br>
  <input type="checkbox" class="parameter" id="Humidity">Humidity<br>
  <input type="checkbox" class="parameter" id="Pressure">Pressure<br>
  <input type="checkbox" class="parameter" id="WindSpeed">Wind Speed<br>
  <input type="checkbox" class="parameter" id="Direction">Direction<br>
  <input type="checkbox" class="parameter" id="RainVolume">Rain Volume<br>
  <input type="submit">
</form>



VBA Code to link checkboxes to certain columns

I have three columns E(insufficient QTY) F(Too Slow) and G(Not Listed) They all have checkboxes in them. I need to link E to H F to I G to J

The following code works nicely if there was only 1 column of checkboxes but I don't know how to improve the code to run by checkboxes in a certain column. Right now it just searches the entire sheet for checkboxes and links them to the desired column.

Sub LinkChecks()
'Update 20150310
i = 2
For Each cb In ActiveSheet.CheckBoxes
cb.LinkedCell = Cells(i, "I").Address
i = i + 1
Next cb
End Sub




Checkbox with ng-model that reflect if another element is showed

I have an element checkbox, that I want to reset the value of ng-model when another element is not showed, example: set to false if another element is not showed in my view. ng-show only hide my checkbox, but not reflect in object of controller.

<select ng-model="item.myOption" convert-to-boolean>
  <option value="false" selected>Option false</option>
  <option value="true">Option true</option>
</select>
<input type="checkbox" ng-model="item.myChecked" ng-show="item.myOption">




Android - Keep values and communicate them while changing of fragments

I have been searching for this for a long time but I didn't find any working answer for me.

I have 2 fragments linked with a bottom navigation view.

  • On fragment 1, there is a checkbox
  • On fragment 2, there is a spinner

I want that when I change of fragment, if the checkbox is unchecked, the spinner is disabled. Moreother, when I come back to the 1st fragment, the checkbox state is kept and the spinner selected item o the second fragment too.




Get the IsChecked property value from a list of checkbox in a combobox

I am writing a program in which I have a combobox made of a series of checkbox. The user can select as many checkboxes as he want. After taht, when he click on a button, I want to check al the checkboxes to see which are selcted and which are not.

But I don't have any idea of how to do that. I tried many ways, but nothing of them returns me the value of the property. In fact, I'm not able to reach the binding property from the code. Here is the code:

In WPF:

<ComboBox x:Name="month_comboBox" Margin="349,107,0,0" Height="22" VerticalAlignment="Top" Visibility="Hidden">
    <ComboBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <CheckBox Width="20" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"/>
                <TextBlock Text="{Binding Path=month_Name}" Width="100" />
            </StackPanel>
        </DataTemplate>
    </ComboBox.ItemTemplate>
</ComboBox>

In the .cs file, this is the code to load the combobx:

In the main class there is this method:

private void LoadMonths()
    {
        MonthList ML = new MonthList();
        month_comboBox.ItemsSource = ML.Months;
        month_comboBox.SelectedIndex = 0;
    }

and there are also this two classes for the elements:

public class MonthList
    {
        ObservableCollection<Month> _Months = new ObservableCollection<Month>();

        public MonthList()
        {
            _Months.Add(new Month { month_Name = "every month" });
            _Months.Add(new Month { month_Name = "january" });
            _Months.Add(new Month { month_Name = "february" });
            _Months.Add(new Month { month_Name = "march" });
            _Months.Add(new Month { month_Name = "april" });
            _Months.Add(new Month { month_Name = "may" });
            _Months.Add(new Month { month_Name = "june" });
            _Months.Add(new Month { month_Name = "july" });
            _Months.Add(new Month { month_Name = "august" });
            _Months.Add(new Month { month_Name = "september" });
            _Months.Add(new Month { month_Name = "october" });
            _Months.Add(new Month { month_Name = "november" });
            _Months.Add(new Month { month_Name = "december" }); 
        }

        public ObservableCollection<Month> Months { get { return _Months; } }

    }

    public class Month
    {
        private string monthName;

        public bool IsSelected {
            get { return IsSelected; }
            set; 
        }

        public string month_Name
        {
            get { return monthName; }
            set { monthName = value; }
        }

    }

Now, what I want is a way to know, for every checkbox in the combobox, if the checkbox is selected or not.

I have this for, but i don't know what instruction put insisde it to obtain the property value:

for (int i = 0; i < month_comboBox.Items.Count; i++) { 
    //Instruction missing here
}

I know that I have to use something similat to this

month_comboBox.Items[i]

but i don't know what I have to hook to it to obtain the property value.

Thank you all




Checkbox unchecked when updating product - php myadmin

I've created an application that allows me to add products, and on the product create_product.php page I am able to check a box telling us whether the product is publish or not. (true or false (1 or 0))

When I go to update the product on update_product.php the checkbox isn't checked even if it was before. I can't seem to get the checkbox to be checked when I go to update the product.

Here is the update_product.php

<?php
// get ID of the product to be edited
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: missing ID.');
 
// include database and object files
include_once 'config/database.php';
include_once 'objects/product.php';
include_once 'objects/category.php';
 
// get database connection
$database = new Database();
$db = $database->getConnection();
 
// prepare objects
$product = new Product($db);
$category = new Category($db);
 
// set ID property of product to be edited
$product->id = $id;
 
// read the details of product to be edited
$product->readOne();


$page_title = "Update {$product->name}";
include_once "header.php";
 
echo "<div class='right-button-margin'>";
    echo "<a href='index.php' class='btn btn-default pull-right'>Read Products</a>";
echo "</div>";

// if the form was submitted
if($_POST){
 
    // set product property values
    $product->name = $_POST['name'];
        $product->family = $_POST['family'];
    //$product->number = $_POST['number'];
    $product->description = $_POST['description'];
        $product->ext_description = $_POST['ext_description'];
    //$product->category_id = $_POST['category_id'];
        
        if(isset($_POST['publish'])){
    $published = $_POST['publish'];
        $product->publish = $_POST['publish'];
        }
        else{
                //$publish is not checked and value=0
                $published = 0;
                $product->publish = 0;
        }
 
    // update the product
    if($product->update()){
        echo "<div class='alert alert-success alert-dismissable'>";
            echo "Product was updated.";
        echo "</div>";
    }
 
    // if unable to update the product, tell the user
    else{
        echo "<div class='alert alert-danger alert-dismissable'>";
            echo "Unable to update product.";
        echo "</div>";
    }
}


?>

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"] . "?id={$id}");?>" method="post">
    <table class='table table-hover table-responsive table-bordered'>
 
        <tr>
            <td>Name</td>
            <td><input type='text' name='name' value='<?php echo $product->name; ?>' class='form-control' /></td>
        </tr>
        <td>Product Family</td>
                <td><select class="selectpicker" name='family'>
                        <option selected="selected" value="<?php echo $product->family; ?>">Selected - <?php echo $product->family; ?></option>
                                <option value="COM Express">COM Express</option>
                                <option value="NVIDIA Jetson TX2/TX1">NVIDIA Jetson TX2/TX1</option>
                                <option value="PC/104">PC/104</option>
                                <option value="SMARC">SMARC</option>
                                </select>
                </td>
        
<!--        
        <tr>
            <td>Category</td>
            <td>
        //     <?php
                //              $stmt = $category->read();

                                // put them in a select drop-down
                //              echo "<select class='form-control' name='category_id'>";

                //                      echo "<option>Please select...</option>";
                //                      while ($row_category = $stmt->fetch(PDO::FETCH_ASSOC)){
                //                              extract($row_category);

                                                // current category of the product must be selected
                //                              if($product->category_id==$id){
                //                                      echo "<option value='$id' selected>";
                //                              }else{
                //                                      echo "<option value='$id'>";
                //                              }
                //
                //                              echo "$name</option>";
                //                      }
                //              echo "</select>";
                                ?>
            </td>
        </tr>
 -->
        <tr>
            <td>Part Number</td>
            <td><?php echo $product->id; ?></td>
        </tr>
        
        <tr>
            <td>External Description</td>
            <td><textarea name='ext_description' class='form-control'><?php echo $product->ext_description; ?></textarea></td>
        </tr>
 
        <tr>
            <td>Interal Description</td>
            <td><textarea name='description' class='form-control'><?php echo $product->description; ?></textarea></td>
        </tr>
        
         <tr>
            <td>Publish</td>
            <td><input type="checkbox" name="publish"  value="1" class="form-control" <?php if(isset($_POST['publish'])) echo "checked='checked'";?>/></td>
        </tr>
 
        <tr>
            <td></td>
            <td>
                <button type="submit" class="btn btn-primary">Update</button>
            </td>
        </tr>
 
    </table>
</form>


<?php

 
// set page footer
include_once "footer.php";
?>

and here is the product class with the update() function..

<?php
class Product{
 
    // database connection and table name
    private $conn;
    private $table_name = "products";
        private $table2_name = "deleted_products";
 
    // object properties
    public $id;
    public $name;
        public $family;
    public $number;
        public $description;
    public $ext_description;
        public $publish;
    public $category_id;
        public $timestamp;
    public $timestamp2;
 
    public function __construct($db){
        $this->conn = $db;
    }
    
    function update(){
 
    $query = "UPDATE
                " . $this->table_name . "
            SET
                name = :name,
                number = :number,
                                family = :family,
                                ext_description = :ext_description,
                description = :description,
                category_id  = :category_id,
                                modified  = :modified,
                                publish = :publish
                                
            WHERE
                id = :id";
 
    $stmt = $this->conn->prepare($query);
 
    // posted values
    $this->name=htmlspecialchars(strip_tags($this->name));
    $this->number=htmlspecialchars(strip_tags($this->number));
        $this->family=htmlspecialchars(strip_tags($this->family));
        $this->ext_description=htmlspecialchars(strip_tags($this->ext_description));
    $this->description=htmlspecialchars(strip_tags($this->description));
    $this->category_id=htmlspecialchars(strip_tags($this->category_id));
    $this->id=htmlspecialchars(strip_tags($this->id));
        $this->publish=htmlspecialchars(strip_tags($this->publish));
        
        //get times of last updated and created date
        $this->timestamp = date('Y-m-d H:i:s');
        $this->timestamp2 = date('Y-m-d H:i:s');
 
    // bind parameters
        
    $stmt->bindParam(':name', $this->name);
    $stmt->bindParam(':number', $this->number);
        $stmt->bindParam(':family', $this->family);
        $stmt->bindParam(':ext_description', $this->ext_description);
    $stmt->bindParam(':description', $this->description);
    $stmt->bindParam(':category_id', $this->category_id);
    $stmt->bindParam(':id', $this->id);
        $stmt->bindParam(":modified", $this->timestamp2);
        $stmt->bindParam(":publish", $this->publish);
 
    // execute the query
    if($stmt->execute()){
        return true;
    }
 
    return false;
     
        }
}
    
    



Checkbox CSS :checked styling

I'm trying to understand where is the problem in my CSS, but I really don't have any clue what is wrong.

Basically, I'm styling the default checkbox style with CSS. It works well until you try to check the checkbox.

The idea behind my code is when you check the checkbox, it should increase the size and change the background colour to red. In addition, it should keep the style till you uncheck the box (manually).

Any idea where is the problem? In my opinion the problem is where the "input[type="checkbox"]:checked .check-box-effect {" begins.

Please find the code below

label {
  display: inline-block;
  color: #fff;
  cursor: pointer;
  position: relative;
}

label .check-box-effect {
  display: inline-block;
  position: relative;
  background-color: transparent;
  width: 25px;
  height: 25px;
  border: 2px solid #dcdcdc;
  border-radius: 10%;
}

label .check-box-effect:before {
  content: "";
  width: 0px;
  height: 2px;
  border-radius: 2px;
  background: #626262;
  position: absolute;
  transform: rotate(45deg);
  top: 13px;
  left: 9px;
  transition: width 50ms ease 50ms;
  transform-origin: 0% 0%;
}

label .check-box-effect:after {
  content: "";
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: #626262;
  position: absolute;
  transform: rotate(305deg);
  top: 16px;
  left: 10px;
  transition: width 50ms ease;
  transform-origin: 0% 0%;
}

label:hover .check-box-effect:before {
  width: 5px;
  transition: width 100ms ease;
}

label:hover .check-box-effect:after {
  width: 10px;
  transition: width 150ms ease 100ms;
}

input[type="checkbox"] {
  display: none;
}

input[type="checkbox"]:checked .check-box-effect {
  background-color: red !important;
  transform: scale(1.25);
}

input[type="checkbox"]:checked .check-box-effect:after {
  width: 10px;
  background: #333;
  transition: width 150ms ease 100ms;
}

input[type="checkbox"]:checked .check-box-effect:before {
  width: 5px;
  background: #333;
  transition: width 150ms ease 100ms;
}

input[type="checkbox"]:checked:hover .check-box-effect {
  background-color: #dcdcdc;
  transform: scale(1.25);
}

input[type="checkbox"]:checked:hover .check-box-effect:after {
  width: 10px;
  background: #333;
  transition: width 150ms ease 100ms;
}

input[type="checkbox"]:checked:hover .check-box-effect:before {
  width: 5px;
  background: #333;
  transition: width 150ms ease 100ms;
}
<label>     
          <input type="checkbox" id="chkProdTomove"  />
          <span class="check-box-effect"></span>
        </label>



retrive value from multiple checkbox in html using angularJS

I have a scenario where any one protocol has to be configured on a device. A web UI will display all the options as a checkbox and I need to retrieve the protocol and device that was checked and send this data via http post to backend server. I am using HTML and AngularJS. Below is my code so far and please suggest if this can be done in a better way.

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


Myapp.controller('CloudController', function($scope,$http)
        {
        $scope.execute = function(ImageLoc, protocol, device)
            {
           # HTTP request will be generated here        
            };
          });
<form>
<h3>Choose the protocol:</h3>
  <input type="checkbox" name="protocol" value=1> L3 Sanity <br>
  <input type="checkbox" name="protocol" value=2> L2 Sanity <br>
  <input type="checkbox" name="protocol" value=3> ROUTING <br>
  <input type="checkbox" name="protocol" value=4> STP <br>
  <input type="checkbox" name="protocol" value=5> VLAN <br>
  <input type="checkbox" name="protocol" value=6> Interface Scale <br>
  <input type="checkbox" name="protocol" value=7> VLAN SCALE <br>
  
<h3>Choose the Device:</h3>
  <input type="checkbox" name="device" value=1> DUT 1 <br>
  <input type="checkbox" name="device" value=2> DUT 2 <br>
  <input type="checkbox" name="device" value=3> DUT 3 <br>
  <input type="checkbox" name="device" value=4> DUT 4 <br>
  <input type="checkbox" name="device" value=5> DUT 5 <br>
  
<h3>Enter Image location:</h3> 
  <input type="text" ng-model="ImageLoc" />
  
  <p><input type="button" value="Launch" ng-click="execute(ImageLoc,protocol,device)"/></p>
</form>



I have dynamically created checkbox. I have an option "Select All". How do I select all the dynamically created checkboxes in c#?

How to select all the dynamic checkboxes which have been created?

protected void chkbox_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox chkBtn = new CheckBox();
            chkBtn = sender as CheckBox;
            selectedTypeId.Add(Convert.ToInt16(chkBtn.Name));
            foreach(int id in selectedTypeId)
            {
                Console.WriteLine(id);

            }
        }




Custom checkboxes with checkbox under text

I'm trying to have custom inline checkboxes with the text aligned above the checkbox. The checkbox has to be horizontally centered compared to the text. It should look like this:

enter image description here

I have tried to add the <br/> tag and moved the text over the control like this:

  <label class="custom-control custom-checkbox">
    <span class="custom-control-indicator"></span>
    <span class="custom-control-description">Check this custom checkbox</span>
    <br />
    <input type="checkbox" class="custom-control-input">
  </label>

without success... you can see the failed plunker here.

This plunker is the normal inline checkboxes of bootstrap v4




Vuejs + Vuex Get checkbox status (checked)

I would like get the checkbox status from store. I made a Comparison with the checkbox list and "active checkbox" list ( inArray(checkList.value, activeFilters) ), but I can't get the value from this.$store.getters.updateFilters. Here the code:

 <template>
    <li class="dropdown-child">
        <label >
            <input
                type="checkbox"
                :name="checkList.id"
                :value="checkList.name"
                :checked="inArray(checkList.value, activeFilters)"
                @change="updateFilter"
                >
            <span></span>

        </label>
    </li>
</template>


<script>

    export default {
        props: ['checkList'],
        computed: {

            inArray (filterValue, filterChecked) {
                const intComparison = /^[+-]?\d+$/.test(filterValue)
                for (let i = 0, l = filterChecked.length; i < l; i++) {
                    if ((intComparison && parseInt(filterChecked[i], 10) === parseInt(filterValue, 10)) || (filterChecked[i] === filterValue)) {
                        return true
                    }
                }
                return false
            },

            activeFilterList(){
                return this.$store.getters.updateFilters;
            }
        },
        methods: {

            updateFilter (evt) {
                const elm = evt.target || evt.srcElement
                const action = elm.checked === false
                    ? this.removeFilter(elm) //elm.checked
                    : this.addFilter(elm)
                const value = /^[+-]?\d+$/.test(elm.value)
                    ? parseInt(elm.value)
                    : elm.value
            },

            addFilter(elm){
                this.$store.dispatch('addFilter', elm);
            },

            removeFilter(elm){
                this.$store.dispatch('removeFilter', elm);
            }

        }
    }
</script>




AngularJS - add a checkbox to a widget

How do I add a checkbox to a widget in AngularJS?

I have a widget displayed on one of my webpages- the widget currently displays a couple of alarms whenever the alarms are raised (i.e. it's watching the value of a couple of variables- when those variables reach a certain value, the alarms are raised, and displayed on the widget).

What I want to do now, is add a checkbox to the widget, to toggle whether or not the alarms should be displayed on the widget. The HTML for the widget is:

<div data-ng-if="widget.name === 'umw-tag-box'">
    <div class="divider"></div>
    <div class="row">
        <div class="form-horizontal">
            <label class="col-sm-4 control-label-left" data-i18n="Tag:"></label>
            <div class="col-sm-8">
                <tags-input max-tags="1"
                            min-length="1"
                            key-property="tag"
                            display-property="tag"
                            template="tagItem.html"
                            um-max-tags-strict="true"
                            data-ng-model="widget.tag"
                            placeholder="Start typing a tag name"
                            replace-spaces-with-dashes="false"
                            on-tag-adding="onAddingTagItem($tag)"
                            on-tag-added="warning.tag = undefined"
                            um-tags-input-warning=""
                            data-ng-class="{'hide-tags-input': widget.tag.length > 0}">
                    <auto-complete min-length="1"
                                   load-on-focus="true"
                                   load-on-empty="true"
                                   display-property="tag"
                                   template="autocomplete.html"
                                   source="autocompleteTagsFilter($query)">
                    </auto-complete>
                </tags-input>
            </div>
        </div>
    </div>
    <div class="divider"></div>
    <div class="row">
        <div class="form-horizontal">
            <label class="col-sm-4 control-label-left" data-i18n="Background color:"></label>
            <div class="col-sm-8">
                <um-color-picker color="widget.color"></um-color-picker>
            </div>
        </div>
    </div>
    <div class="divider"></div>
    <div class="row">
        <div class="form-horizontal">
            <label class="col-sm-4 control-label-left" data-i18n="Background icon:"></label>
            <div class="col-sm-8 ">
                <um-icon-picker icon="widget.icon"></um-icon-picker>
            </div>
        </div>
    </div>
    <div class="divider"></div>
    <div class="row ui-checkbox-row">
        <label class="col-sm-4 col-xs-6" data-i18n="Flip:"></label>
        <div class="col-sm-8 col-xs-6">
            <label class="ui-checkbox">
                <input type="checkbox" ng-model="widget.flip">
                <span></span>
            </label>
        </div>
    </div>
    <div class="divider"></div>
    <div class="row" ul-scroll-modal-to-me="focusDesc">
        <div class="form-horizontal">
            <label class="col-sm-4 control-label-left" data-i18n="Description:"></label>
            <div class="col-sm-8">
                <input type="text" class="form-control input-sm" ng-model="widget.description"
                       data-ng-focus="focusDesc = true" data-ng-blur="focusDesc = false">
            </div>
        </div>
    </div>
</div>

Inside the widget HTML, there is already what appears to be markup for a checkbox, though I can't actually see that on the page anywhere...

<div class="row ui-checkbox-row">

I tried adding a similar line inside the umw-tag-box div, and inside the divs a couple of levels below that, but couldn't get the checkbox to appear no matter where I placed it...

What is the best way to add a checkbox to the widget?




Checkbox is not disabled after checking other checkbox

I have 2 checkboxes:

<div><input type="checkbox" id="dx_article_excerpt"><label for="dx_article_excerpt"><?php _e( 'Displayyyyyyyy Excerpt', 'dxeasypb' ); ?></label></div>
<div><input type="checkbox" id="dx_article_content"><label for="dx_article_content"><?php _e( 'Display Content', 'dxeasypb' ); ?></label></div>

I want when the first is clicked, the content checkbox to be disabled automatically. I've tried the following thing:

if (document.getElementById('dx_article_excerpt').checked) {
        document.getElementById("dx_article_content").disabled = true;
}

But guess what.. it's not working.




Normal Checkbox to look like Intermediate Checkbox using CSS without JavaScript

How can I convert a normal Checkbox to look like an intermediate checkbox using CSS without JavaScript?

Normal Checkbox

Intermediate Checkbox




Struts2 Multiple CheckBox inside a Form Get Value Checked

Good morning:

I am having so many problems with my java-jsp trying to get the values of the checkbox in a jsp to java.

There are dynamic checkboxes due to the number of reports there are on the data base.

Mi jsp is

<s:checkbox name="reportFactured<s:property value='id'/>" id="reportFactured" fieldValue="reportFactured<s:property value='id'/>" label="Factured" theme="simple"/>

I am trying to recover variables like "reportFactured3" or "reportFactured9", depends on which one are checked or not.

My .Java is:

import org.apache.struts2.interceptor.SessionAware;

public class PostIntroducirFacturaInforme extends ActionSupport implements SessionAware {

private ArrayList arrayFacturedReport = new ArrayList();

public String execute() throws Exception
{

    for(int i=0; i <= 100; i++)
    {
        arrayFacturedReport (i);

        System.out.println("FACTURED REPORT " + i + " == " + arrayFacturedReport.get(i).toString());
    }

    return "success";
}

//Getters y Setters

public ArrayList<Boolean> arrayFacturedReport () {
    return arrayFacturedReport ;
}

public void setArrayFacturedReport (ArrayList<Boolean> arrayFacturedReport ) {
    this.arrayFacturedReport = arrayFacturedReport ;
}   }

But the results are all false:

FACTURED REPORT 1 == false
FACTURED REPORT 2 == false
FACTURED REPORT 3 == false
FACTURED REPORT 4 == false
FACTURED REPORT 5 == false
FACTURED REPORT 6 == false
FACTURED REPORT 7 == false

I tried different methods but all do the same.

Does anybody know how can I get the different values on the jsp (i am not sure if is ok, and recover them on JAVA?

Thanks.




Need to have tri-state checkbox on the Kendo grid using jquery/javascript

I want to have the tri-state checkbox on the kendo grid on load. User can then override that state either to checked or unchecked. I tried using the document.ready & using template or using editor. However, the problem is it works only when the component is rendered. I need to have an handle when everything on the grid is rendered & then I can get hold of check boxes & change them to indeterminate on conditional basis.




Dynamic Forms Angular 2 - Checkbox

I am new in Angular 2. I am trying to expand dynamic forms according to http://ift.tt/2sPAe7i. I did input radios and work as I need. But now I am trying to do checkboxes, but there is a problem. I have a group of checkboxes and I get only boolean value, if some checkbox is checked. Bud I need values, which checkboxes is checked. There is my plunker: http://ift.tt/2sl3zmM

Thanks for help!




mardi 27 juin 2017

Assigning value to checkboxes through ng-model

I have a checkbox that I want to have a value=0. I have also assigned a ng-moel to it

<input type="checkbox" class="input-group inline form-control" value="0" name="" id="deletelanguage" ng-show="IsVisible" ng-model="delStat">

The scope in my controller looks like this.

$scope.delStat="";

I want to changed the value of the checkbox to 1 if it is checked. How can I do that?




Unchecked the Checkbox while looping threw array in for loop

I have the Check box of all the week days.

HTML code is here:

<div class="col-lg-10">

    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="monday" name="working_days[]" value="1" checked>
        <label for="monday"> Monday </label>
    </div>

    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="tuesday" name="working_days[]" value="2" checked>
        <label for="tuesday"> Tuesday  </label>
    </div>

    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="wednesday" name="working_days[]" value="3" checked>
        <label for="wednesday"> Wednesday  </label>
    </div>

    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="thursday" name="working_days[]" value="4" checked>
        <label for="thursday"> Thursday </label>
    </div>
    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="friday" name="working_days[]" value="5" checked>
        <label for="friday"> Friday  </label>
    </div>
    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="saturday" name="working_days[]" value="6" checked>
        <label for="saturday"> Saturday  </label>
    </div>
    <div class="checkbox checkbox-custom checkbox-inline">
        <input type="checkbox" id="sunday" name="working_days[]" value="7" checked>
        <label for="sunday"> Sunday  </label>
    </div>

</div>

User Simply uncheck the day which he/she don't want to check. I save the days in comma separated string in the database as:

1,2,4,5

Now I am Fetching it using Ajax. I get the string back in the ajax response.

The Problem

I am not able to uncheck the days which user uncheck before. Or I say I want to display only the checked days as checked and want to uncheck the days which is not checked by use.

What is have tried so far?

I have created an array from the string by using split.

var working_day_string = response.working_days;   // response.working_days = 1,2,4,5
var working_day_array = working_day_string.split(',');

After getting an array I use For loop to uncheck the checkbox but it did not working.

for (i=0;i<working_day_array.length;i++){ 
   working_day_array[i] != '1' ? $('#monday').prop('checked', false) : '';         
}

But I My Monday checkbox is getting uncheck.




Why can't I add a newly created checkbox to a checkbox list in Java? [duplicate]

This question already has an answer here:

I'm getting a null point exception at this line:

primaryList.add(primaryBox);

Here is the relevant code:

private List<JCheckBox> primaryList;
private newTablePane = new JPanel();
private int count = 0;

public void addRow(){
JPanel row = new JPanel();
row.setLayout(new FlowLayout());
JCheckBox primaryBox = new JCheckBox("Primary Key");
primaryList.add(primaryBox);
row.add(primaryList.get(count));
newTablePane.add(row);
count++;
}

Here is the full error message:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at NewTableDialog.addRow(NewTableDialog.java:67)
    at NewTableDialog$MyActionListener.actionPerformed(NewTableDialog.java:133)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

What's the reason behind the null point exception? The object is clearly instantiated and is not null or anything.




JQuery reset value of text input when checkbox is unchecked

I have a fieldset in my form that has a check box tied to a text input. When the checkbox is checked/unchecked it toggles the readonly attribute of the text input.

When the checkbox is unchecked I would like the text input value to reset to 0.

Here is my

<label for="device-9102" class="form-partner-label"><input type="checkbox" class="quote-chkbox" id="9102-chk"> 9102 IP Phone</label>
<input type="text" name="9102-quantity" class="form-endpoint-qty form-control" id="form-partner-9102" readonly value="0">

Here is the JQuery that currently sets the readonly value for the text input:

$("#9102-chk").change(function() {
        $("#form-partner-9102").prop("readonly", !$(this).is(":checked"));
});

How do I reset the value of the text input to 0 when the checkbox is unchecked?




how to add checkbox in firebase list adapter android

I have got to add checkboxes in the firebase list adapter and set the adapter in the list view. I can click in the checkbox but when I click to the actual item from list view it doesn't send me to the detail activity to edit the list. If someone can point me to the right direction I really appreciate.

here is my BaseActivity

public class BaseActivity extends AppCompatActivity {

    private ListView list;
    protected SearchView searchView;
    private String FirebaseID;
    FirebaseUser  mCurrentUser;
    Firebase mDatabaseRef;
    FirebaseListAdapter <Career> mAdapter;
    CheckBox check ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

       Firebase.setAndroidContext(this);


        mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();

   String current_uid = mCurrentUser.getUid();

        mDatabaseRef = new Firebase(Constant.FIREBASE_URL).child("Users").child(current_uid).child("description");
       // mDatabaseRef = FirebaseDatabase.getInstance().getReferenceFromUrl(Constant.FIREBASE_URL).child("description").child(current_uid);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        list = (ListView) findViewById(R.id.listView);


        mAdapter = new FirebaseListAdapter<Career>(
                this,
                Career.class,
                R.layout.career,mDatabaseRef
                ) {
            @Override
            protected void populateView(View view, Career career, int position) {
                ((TextView)view.findViewById(R.id.description)).setText(career.getDescription());
                ((TextView)view.findViewById(R.id.date)).setText(career.getDate());
                ((TextView)view.findViewById(R.id.title)).setText(career.getTitle());

            }
        };



        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

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

                Intent inte = new Intent(getApplicationContext(), DetailActivity.class);
                inte.putExtra("FirebaseID", mAdapter.getRef(position).getKey());
                startActivityForResult(inte, 0);


            }
        });


        registerForContextMenu(list);

    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);

        SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
        searchView = (SearchView) menu.findItem(R.id.pesqContato).getActionView();

        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));

        searchView.setIconifiedByDefault(true);
        return true;
    }

    @Override
    public void onCreateContextMenu(ContextMenu menu, View v,
                                    ContextMenu.ContextMenuInfo menuInfo) {
        super.onCreateContextMenu(menu, v, menuInfo);
        MenuInflater m = getMenuInflater();
        m.inflate(R.menu.menu_context, menu);
    }


    @Override
    public boolean onContextItemSelected(MenuItem item) {

        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        list.getAdapter();


        FirebaseID = mAdapter.getRef(info.position).getKey().toString();

        switch (item.getItemId()) {
            case R.id.delete_item:
                mDatabaseRef.child(FirebaseID).removeValue();
                Toast.makeText(getApplicationContext(), "Contact Successfully deleted", Toast.LENGTH_SHORT).show();
                return true;
        }
        return super.onContextItemSelected(item);
    }


    public void buildListView() {

        list.setAdapter(mAdapter);
        check = (CheckBox) findViewById(R.id.checkBox);
    }

    protected void buildSearchListView(String query) {
        list.setAdapter(mAdapter);
    }

}

Detail Activity

public class DetailActivity extends AppCompatActivity {

private Career career;
private String FirebaseID;
private EditText titleText;
private AutoCompleteTextView descriptionText;
private EditText dateText;
private Button button;
private DatabaseReference myDatabaseRef;
FirebaseUser mCurrentUser;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);


   Firebase.setAndroidContext(this);

    mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();

    String current_uid = mCurrentUser.getUid();


    myDatabaseRef = FirebaseDatabase.getInstance().getReference().child("Users").child(current_uid).child("description");
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle("Add your Goal");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    button = (Button) findViewById(R.id.button);


    if (getIntent().hasExtra("FirebaseID")) {

        FirebaseID = getIntent().getStringExtra("FirebaseID");
        DatabaseReference refCareer = myDatabaseRef.child(FirebaseID);



         refCareer.addValueEventListener(new com.google.firebase.database.ValueEventListener() {
            @Override
            public void onDataChange(com.google.firebase.database.DataSnapshot dataSnapshot) {

                career = dataSnapshot.getValue(Career.class);
                if (career != null) {

                    HashMap<String, Career> userMap = new HashMap<String, Career>();



                    titleText = (EditText) findViewById(R.id.editText3);
                    titleText.setText(career.getTitle());

                    descriptionText = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
                    descriptionText.setText(career.getDescription());

                    dateText = (EditText) findViewById(R.id.editText2);
                    dateText.setText(career.getDate());



                    userMap.put("description",career);


                }

            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }

        });

    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {

    getMenuInflater().inflate(R.menu.detail, menu);
    if (FirebaseID == null) {
        MenuItem item = menu.findItem(R.id.delContact);
        item.setVisible(false);
    }
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
        case R.id.saveContact:

            save();

            return true;
        case R.id.delContact:

            myDatabaseRef.child(FirebaseID).removeValue();
            Toast.makeText(getApplicationContext(), "Contact successfully deleted", Toast.LENGTH_SHORT).show();
            finish();

            return true;

        default:
            return super.onOptionsItemSelected(item);
    }

}

public void save() {
    String description = ((AutoCompleteTextView) findViewById(R.id.autoCompleteTextView)).getText().toString();
    String date = ((EditText) findViewById(R.id.editText2)).getText().toString();
    String title = ((EditText) findViewById(R.id.editText3)).getText().toString();


    if (career == null) {
        career = new Career();
        career.setTitle(title);
        career.setDescription(description);
        career.setDate(date);


        myDatabaseRef.push().setValue(career);
        Toast.makeText(this, "Contact successfully Added!!!", Toast.LENGTH_SHORT).show();
    } else {

        career.setTitle(title);
        career.setDescription(description);
        career.setDate(date);


        myDatabaseRef.child(FirebaseID).setValue(career);

        Toast.makeText(this, "Contact successfully Edited!!!", Toast.LENGTH_SHORT).show();
    }

    finish();
}

}

   <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://ift.tt/nIICcg"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >


    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="26sp"
    />


    <TextView
        android:id="@+id/description"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="19sp" />

    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        />

    <CheckBox
        android:id="@+id/checkBox"
        android:layout_width="25dp"
        android:layout_height="wrap_content"
        android:layout_gravity="right|center"
        android:layout_marginRight="2dp"
        android:gravity="right|center" />


</LinearLayout>

And here where I have the list view

    <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://ift.tt/nIICcg"
    xmlns:app="http://ift.tt/GEGVYd"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context=".activity.MainActivity">

    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/listPreferredItemHeight"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />


    </android.support.design.widget.AppBarLayout>



    <ListView
        android:id="@+id/listView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_below="@+id/fab"
        android:padding="16dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="58dp"
        android:layout_height="54dp"
        android:layout_gravity="bottom|end"
        android:layout_marginBottom="25dp"
        android:layout_marginRight="20dp"
        android:focusable="true"
        android:src="@android:drawable/ic_menu_edit"
        app:elevation="24dp" />


</android.support.design.widget.CoordinatorLayout>




How can I update the Database on a checkbox change in MVC

I am trying to update my database when a checkbox is checked or unchecked. I want it to update when the checkbox is clicked. This is what I have so far, but my controller is never being hit. what can I do to fix it? Ideally I want to pass in the new value of customer.IsDone and customer.Id to my controller but I don't know how to do this.

Checkbox in my view

    <td>@Html.CheckBoxFor(m => customer.IsDone, new { onclick = "UpdateCustomer(IsDone)" })</td>

The function in my view

function UpdateCustomer(isDone) {
        $.ajax({
            type: 'POST',
            url: @Url.Action("UpdateCustomer", "Home"),
            data: { check: isDone },
            success: success,
            dataType: 'json'
        });
    }

this is my controller method

    [HttpPost]
    public ActionResult UpdateCustomer(bool check)
    {
        //code will be here to update the db

        var customers = new CustomerGetAll();
        var list = customers.Execute();

        return View("Customers", list);
    }




Select statement with textboxes and checkboxes in c#

I'm trying to build a query that will allow me to search via text box and check box at the same time , but am getting a returned value of no record each time and cannot determine why.

con.Open();


        string str = "Select * from engineering where Education = @Education AND JobNumber like '%' + @search + '%'  ";

        SqlCommand xp = new SqlCommand(str.ToString(), con);


        xp.Parameters.Add("@search", SqlDbType.NVarChar).Value = txtProjectNumber.Text;
        xp.Parameters.Add("@Education", SqlDbType.Int).Value = chkEducational.CheckState;




        try
        {
            da = new SqlDataAdapter();
            da.SelectCommand = xp;
            da.Fill(ss);
            Showdata(pos);
            DataSet ds = new DataSet();
            da.Fill(ds, "ss");
            dataGridView1.DataSource = ds.Tables["ss"];
        }
        catch
        {
            MessageBox.Show("No Record Found");

        }
        con.Close();

above is the code to my search button. There is no need to worry about the Showdata(pos) because that is there only to scroll through the returned results. The query will work if I take out the Education = @Education , or JobNumber = '%' + @search1 + '%' , just not together for some reason. Any help on this would be greatly appreciated.




How to put checked checkbox in php foreach?

I actually try to put some checked checkbox in foreach but i have a problem with it. Because i think foreach don't get a array and it return this message: Warning: Invalid argument supplied for foreach()

There is my main page with checkbox:

<form class="form" action="resultat.php" method="POST">
<?php require_once 'script.php'; 
$num=$_GET["flux1"];
if($num==1){
    $url ="http://ift.tt/1pXVAu7"; 
    info($url);

}
elseif ($num==2) {
    $url="http://ift.tt/2sdKyYc";
    info ($url);
}
elseif($num ==3){   
    $url='http://ift.tt/2sdKyYc';
    info ($url);
}

?>

<input type ="submit" name="valider" value="valider">
</form>

There is my php function to treat rss and put checkbox close to them:

function info($url){
//Load RSS
if ( $flux=simplexml_load_file($url) ) {
 $donnee = $flux->channel;
 //Read data
 foreach( $donnee->item as $valeur ) {
 //return data
  print('<p>'.date("d/m/Y",strtotime($valeur->pubDate)).' - <a 
   href="'.$valeur->link.'">'.$valeur->title.'</a>'."\n");
  print('<br/>'.$valeur->description.'<input type="checkbox" name='.$valeur-
   >title' value='.$valeur->link.>'Selectioner le flux RSS</p>'."\n");
 }
} else{
   print('Eror');
  }
}

and this is my final web page with the rss selected:

<!DOCTYPE html>
<html>
<head>
<title>Resultat</title>
</head>
<body>
   <?php
       $rss= $_POST['checkbox'];

      if(isset($_POST['checkbox'])) {

        echo "Voulez vous selectioner les flux suivant ? <br>";

        foreach ($name as $flux){
            echo $flux."<br />";

        }

    } // end brace for if(isset

    else {

        echo "You did not choose a color.";

    }
  ?>    
</body>
</html>

I think i must put the checked checkbox in array but i don't realy see how to do that can you please help me ? :)




Shiny - access individual checkbox items by id

Is there a way to access individual checkbox items in a checkboxGroupInput by id so that these can be modified individually through css?

Example:

using the following:

#id input[type="checkbox"]:checked:after {
                background-color: #FE0004;
}

I can edit all checkboxes inside a checkboxGroupInput. I now want to edit each individual checkbox within a group. Does each option have a unique id?




Error when checkbox not checked in php mysql form

The checkbox in my form works to put in a true value (1) when the checked and otherwise, the value for the column is false (0).. however, when I run the form without the checkbox checked it gives me this error -

"Notice: Undefined index: publish in C:\xampp\htdocs\phpoop\create_product.php on line 37"

Here is the Product class for creating the product (only including the publish variable)

class Product{

    // database connection and table name
    private $conn;
    private $table_name = "products";

    // object properties
      public $publish;


    public function __construct($db){
        $this->conn = $db;
    }

    // create product
    function create(){

        //write query
        $query = "INSERT INTO
                    " . $this->table_name . "
                SET
                    publish=:publish";

        $stmt = $this->conn->prepare($query);

        // posted values
        $this->publish=htmlspecialchars(strip_tags($this->publish));

        // to get time-stamp for 'created' field
        $this->timestamp = date('Y-m-d H:i:s');
        $this->timestamp2 = date('Y-m-d H:i:s');

        // bind values 
        $stmt->bindParam(":publish", $this->publish);


        if ($stmt->execute()){
            return true;    

        }else{
            return false;
        }

    }

and this is where the form is located for creating the product

// if the form was submitted 
if ($_POST){

    // set product property values
    $product->publish = $_POST['publish'];

    if(isset($_POST['publish'])){
    $published = $_POST['publish'];
    }
    else{
        $published = 0;
    }

    // create the product
    if($product->create()){
        echo "<div class='alert alert-success'>Product was created.</div>";
    }


}

?>

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
  <input type="checkbox" name="publish"  value="1" class="form-control" <?php if(isset($_POST['publish'])) echo "checked='checked'";?>/>
  <button type="submit" class="btn btn-primary">Create Product</button>
 </form>




How do I save my checkbox tick to local storage

My question is how do I save the checkbox so that when i reopen or reload the page it stays like that for example when i tick it, it stays tick and when i untick it it stays untick

what i have so far:

html>

head>

title>MY DATABASE/title>

meta charset="UTF-8">

style>

        #myInput {
            background-image: url('http://ift.tt/2shp6Na');
            background-position: 10px 10px;
            background-repeat: no-repeat;
            width: 100%;
            font-size: 16px;
            padding: 12px 20px 12px 40px;
            border: 1px solid #ddd;
            margin-bottom: 12px;
        }

        #myTable {
            border-collapse: collapse;
            width: 100%;
            border: 1px solid #ddd;
            font-size: 18px;
        }

        #myTable th, #myTable td {
            text-align: left;
            padding: 12px;
        }

        #myTable tr {
            border-bottom: 1px solid #ddd;

        }

        #myTable tr.header, #myTable tr:hover {
            background-color: #f1f1f1;

        }

        * {
            box-sizing: border-box;
        }
</style>

/head>

body>

<h2>DATABASE</h2>

<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for an name.." title="Type in an name">

<table id="myTable">
    <tr class="header">
        <th style="width:60%;">Anime</th>
        <th style="width:40%;">Email</th>
        <th style="width:auto;">PTW</th>
    </tr>
    <tr>
        <td>name1</td>
        <td>email1</td><td><input type="checkbox" id="checkbox" class="checkbox"></td>
    </tr>
    <tr>
        <td>name2</td>
        <td>email2</td><td><input type="checkbox" id="checkbox" class="checkbox"></td>
    </tr>
    <tr>
        <td>name3</td>
        <td>email3</td><td><input type="checkbox" id="checkbox" class="checkbox"></td>
    </tr> 
    </table>
    <!--Search Filter-->
    <script>
        function myFunction() {
          var input, filter, table, tr, td, i;
          input = document.getElementById("myInput");
          filter = input.value.toUpperCase();
          table = document.getElementById("myTable");
          tr = table.getElementsByTagName("tr");
          for (i = 0; i < tr.length; i++) {
            td = tr[i].getElementsByTagName("td")[0];
            if (td) {
              if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
                tr[i].style.display = "";
              } else {
                tr[i].style.display = "none";
              }
            }
          }
        }
    </script>
    <script>
enter code for saving checkboxes here
    </script>
</body>
</html>

PS a working version of this on https://54x1.github.io/




Is it possible to combine several (form) search fields into one with checkboxes and/or dropdown?

I am using my own starting page for my browsers. This page is used by myself only (and some friends and family). Which contains news, weather, links and such.

Also this page includes several search fields, like Google, Usenet, forumsearch (on a favourite website) and a subtitles search field. Ofcourse each search field uses different queries for different sites.

Now as I am redoing the starting page, I am wondering if it's possible to create just one search field and use checkboxes to select the page I want to search. By default it should check Google, but if I select the checkbox for subtitles it would use the search field to search for subtitles (on the appropiate website).

If this isn't possible, would it be possible with a dropdown or something similar? Or maybe a different approach or solution to this?

When both are not possible or takes a massive amount of coding / tweaking, I will refer to using multiple search fields as I did before.

I took a screenshot of how the search fields are currently (on the old design) to give you an impression.

enter image description here

Reason for switching to checkboxes / dropdown field is, is that I can add more searches without making the page look messy.

While typing this and looking at things, once more, maybe a better solution would be to just create several buttons and use only one search field? Still might be a little tacky, but that could actually work. What do you think?

And like I said; if it takes to much coding or tweaking just tell so. I am just wondering if there is a different approach to this.




A checked checkbox is not displaying checked? Laravel

i have a problem where a checked checkbox is not displaying checked.

My view:

@if(in_array($searchgroup->id.','.$searchtag->id, session()->get('zoektermen')))
     
@else
     
@endif

I'm using laravel collective.

I'm using this code on other places on the website in different scenario's, where this works perfectly and the checkboxes display checked.

I'm using firefox but i also tried safari, no difference. enter image description here

Any help is appreciated..




DataGrid BindingSource Checkbox Filters

I have a DGrid that is attached to a BindingSource which is full of data. I am trying to use checkboxes for the user to filter out data in a specific column named 'Status'. I have four checkboxes as there will be four different data text in the same column (Column is on the far right). Picture here

Obviously when the user checks/unchecks one of the checkbox it will set a filter to the grid to add/remove that data in the column.

How would I go about doing this? Obviously I would attach a CheckChanged function to each checkbox and apply the filter using bs.Filter but what would be the best way to check if the other checkboxes are checked and aren't checked so I can concat the filter string? Would I have to use a ton of If statements for each checkbox to see if it's checked?




Angular 4 : How to assign array of string into checkbox in reactive forms

I am trying display checkboxes for my user roles:

For eg. I have two user roles : 1.Admin 2.Employee

I have an array of roles in userObject:

user={
    "name":"Bhushan",
    "email":"bhushan@yaho.com",
    "roles":['Admin','Employee']
}

I want to use reactive form to populate this model into form. I want to populate the roles array into read-only checkboxes i.e. when form loads, user can edit name & email but checkboxes will show admin toggeled if user has admin role or untoggled if he is not an admin. same can be said for employee role.

So far I have tried following:

<form [formGroup]="userForm" (ngSubmit)="onSubmit()" novalidate>
  <div style="margin-bottom: 1em">
    <button type="submit" [disabled]="userForm.pristine" class="btn btn-success">Save</button> &nbsp;
    <button type="reset" (click)="revert()" [disabled]="userForm.pristine" class="btn btn-danger">Revert</button>
  </div>
  <div class="form-group">
    <label class="center-block">Name:
        <input class="form-control" formControlName="name">
    </label>
  </div>
  <div class="form-group">
    <label class="center-block">Email:
        <input class="form-control" formControlName="email">
    </label>
  </div>
  <div class="form-group" *ngFor="let role of roles;let i=index">
    <label>
        // I tried this, but it doesn't work
        <!--<input type="checkbox" [name]="role" [(ngModel)]="role">-->
       
    </label>
  </div>
</form>

<p>userForm value: </p>`

Any Inputs?




bootgrid change checkbox into radiobutton

I'm using jQuery-Bootgrid to create my tables. If I set rowSelect=true and multiSelect=falsethe checkbox can not be clicked (or checked).

I want to change the checkbox into a radiobutton if rowSelect=true and multiSelect=false. I don't know how to change this without editing the jquery.bootgrid.js file. Otherwise I don't know how to change this if I edit jquery.bootgrid.js.

The question is, how to :D