mardi 31 janvier 2017

Angular checkbox select all or select individual element from the table

I have two scenarios here, one is user click an individual element and submits and other is user clicks select all button and submits so that, on the user's requirement, I want to fetch the item's details in the controller. Please help me out.

here is my code

HTML

        <div ng-repeat="item in vm.items">
          <label class="btn btn-info">
            <input ng-model="vm.selectAll" type="checkbox"  name="selectAll" value="allitems" > Select all Items
          </label>
          <button ng-click="vm.purchaseItems(item)" class="btn btn-danger" type="submit" >Purchase selected Items</button>
       <table >
          <tbody>
              <thead>
                <th ><input type="checkbox" ng-checked="vm.selectAll"/></th>
                <th >Student Id</th>
                <th >Name</th>
                <th >School</th>
             </thead>
              <tr>
                <td></td>
                <td ></td>
                <td ></td>
                <td ></td>
            </tr>
            </tbody>

        </table>
     </div>

Controller

 vm.purchaseItems = purchaseItems;

  function purchaseItems(item) {
  console.log(item); 
// I want to log only selected items either single or all based on user call
}

Should I go with a directive or can it be done simply in the controller itself need a suggestion




HTML Checkbox, Show current value 1/0 from server db, user check/uncheck and update db

Background - I have a RPI with several IR Beams, PIRs and reed switches around the house connected. A Python script monitors the states of pins and announces audibly via a wireless baby monitor if there is a trigger. There is a bank of toggle switches attached to the I/O pins to disable individual zones or change behavior like send sms or email video grabs via the Python script. The Pi is also a LAMP server and the Python script logs events in MySQL. The logs can be viewed via web browser.

My aim is to remove the bank of toggle switches and replace with check boxes in a web form, updating values 0 or 1 in db which then the Python script will use. I have been putting together a single example code to get it working before I expand it to the dozen or so values I want to control.

What I am trying to do with the code below is upon opening the webpage have the checkbox display current db value and if the user checks/unchecks the box and hits submit then the db is updated and the page refreshes to the up to date information. My code doesn't quite behave as I want as it only returns a zero to the database regardless of the state of the checkbox when the "submit" button is activated.

Any help is greatly appreciated.

<!DOCTYPE html>
<html>
<head>
<title> checkbox wip</title>

<meta name="viewport" content="width=device-width; initial-scale=1.0">

<link rel="stylesheet" href="style.css">


</head>

<body>

<?php
$servername = "localhost";
$username = "*****";
$password = "*****";
$dbname = "Monitor";


$conn = mysqli_connect($servername, $username, $password, $dbname);


if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$thesql = "SELECT event FROM sw_sleep ORDER BY id DESC LIMIT 1";
$result = mysqli_query($conn, $thesql) or die(mysqli_error($conn));
$row_result = mysqli_fetch_assoc($result);

$SSwA = $row_result['event'];


mysqli_close($conn); 

?>
<form action="update.php">
Sleep<input type="checkbox" id="sleepstat" name= "sleepstat1" value="1">    <br/>

<script>
   document.getElementById("sleepstat").checked = <?php echo $SSwA?>;
</script>


<input type="submit" value="Submit">

</form>

</body>
</html>

And this is update.php

<?php
$servername = "localhost";
$username = "******";
$password = "******";
$dbname = "Monitor";

$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$val = $_POST['sleepstat1'];
$sql="INSERT INTO sw_sleep (event) VALUES ('$val')";

if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}


mysqli_close($conn);

header("Location: index.php");




Trying to add "label" to CheckBox Responses Plus App Keeps Shutting Down

Good Evening,

I am trying to create an app that features three radio buttons, two checkboxes and two buttons. The app must feature three "labels" or responses to the user pushing a button or checking a checkbox etc. Now for my two buttons I have successfully completed the needed coding for the UPS or FedEx buttons to send the user to their respective websites. For my final label, I want the response to the checkboxes being checked to be "Your extra item has been added to your cart total," or something along those lines. I know I need an On set listener but I am not sure where or how to string that into my code. Also, every time I try to use the radio buttons or check boxes, the app closes and I am not sure what I am missing. Thank you for the help in advance.

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;



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

public void UPS (View view) {
    goToUrl ( "http://www.ups.com/");
}

public void FedEx (View view) {
    goToUrl ( "http://www.fedex.com/");
}

private void goToUrl (String url) {
    Uri uriUrl = Uri.parse(url);
    Intent launchBrowser = new Intent(Intent.ACTION_VIEW, uriUrl);
    startActivity(launchBrowser);
}

}




unknown error -django 1.8 checkbox widget/boolean field

In modal there is a field

anonymous = models.BooleanField(default=True)

This a form:

class QuestionForm(forms.ModelForm):
question = forms.CharField(required=True, label='', max_length=5000, widget=forms.widgets.Textarea(attrs={'class': 'question_textarea','placeholder':'Write your question here'}))
anonymous = forms.BooleanField(initial=True, widget=forms.widgets.CheckboxInput(attrs={'class': 'anonymous_checkbox'}))
class Meta:
        model = Question
        fields = ('question','anonymous',)

When anonymous field is selected in html(as default) the form works, but otherwise I get unknown error:

{"error":{"type":"http","message":"unknown error"}}

What am I doing wrong and how to fix?




Uniform and jQuery's Form.Serialize() ignores checked checkboxes

I'm using jQuery 3.1.1 (the latest version as of this post) and the Uniform plugin (just including in case this matters - likely doesn't) to make checkboxes look nice.

I'm encountering the following:

  1. Within a Form, I'm using MVC/Razor's CheckBoxFor to render a regular checkbox input and hidden additional input for the checkbox in addition to other inputs. This results in code like this:

    <input id="mycheckbox" name="mycheckbox" type="checkbox" value>

    <input name="mycheckbox" type="hidden" value>

  2. For test purposes, I'm checking the box on the UI.

  3. I verified that the checkbox input is now true (via $("#mycheckbox").prop("checked")) but the hidden input is false (same verification). I'm not sure if this is the culprit or not - in that case it may be a uniform issue.
  4. When then calling $form.serialize() on that form, both inputs (checkbox and hidden) are serialized to nothing, meaning &mycheckbox=&mycheckbox=

So, two issues:

  1. Somehow serialize() doesn't get that the regular checkbox input is checked
  2. There is double-serialization, but I suppose serialize() is just grabbing all input's so this is probably fine.

How can I solve #1?




Not sure how to use switch method

I'm trying to make the app add a topping only if the box is checked. I was following a lesson and they showed me how to display the String with the true or false statement next to it. I don't want that. I actually want the string to appear only if the checkbox is checked. Thank you.

Hi this is the XML:

   <EditText
       android:id="@+id/edit_text"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:hint="Enter your Name"
       android:layout_margin="16dp"/>

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/chocolateCheckBox"
    android:text="Add Chocolate On Your Coffee"
    android:layout_margin="16dp"
    android:layout_below="@id/edit_text"
    />
<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/creamCheckBox"
    android:text="Add Cream On Your Coffee"
    android:layout_marginLeft="16dp"
    android:layout_marginBottom="8dp"
    android:layout_below="@id/chocolateCheckBox"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="QUANTITY"
    android:id="@+id/quantity"
    android:textSize="16sp"
    android:layout_marginTop="16dp"
    android:layout_marginLeft="16dp"
    android:layout_below="@id/creamCheckBox"
    />


<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_margin="16dp"
    android:id="@+id/adding_layout"
    android:layout_below="@id/quantity">

    <Button
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:text="-"
        android:onClick="decrement"
        android:id="@+id/minus_button"
        android:width="48dp"
        android:height="48dp"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="0"
        android:id="@+id/quantity_text_view"
        android:textSize="16sp"
        android:textColor="#000000"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"/>
    <Button
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:text="+"
        android:onClick="increment"
        android:id="@+id/plus_button"/>
</LinearLayout>


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/order_summary"
    android:text="ORDER SUMMARY"
    android:textSize="16sp"
    android:layout_below="@id/adding_layout"
    android:layout_marginLeft="16dp"/>


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="0"
    android:id="@+id/order_summary_text_view"
    android:textSize="16sp"
    android:layout_margin="16dp"
    android:layout_below="@id/order_summary"
    android:textColor="#000000"/>


<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/order_button"
    android:text="ORDER"
    android:layout_marginLeft="16dp"
    android:layout_below="@id/order_summary_text_view"
    android:onClick="submitOrder"/>

  </RelativeLayout>
  </ScrollView>

and this is the java code:

public class MainActivity extends AppCompatActivity {

/**
 * ATTENTION: This was auto-generated to implement the App Indexing API.
 * See http://ift.tt/1Shh2Dk for more information.
 */
private GoogleApiClient client;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See http://ift.tt/1Shh2Dk for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
int quantity = 0;

public String submitOrder(View view) {
    CheckBox addChocolate = (CheckBox) findViewById(R.id.chocolateCheckBox);
    boolean hasChocolate = addChocolate.isChecked();

    CheckBox addCream = (CheckBox) findViewById(R.id.creamCheckBox);
    boolean hasCream = addCream.isChecked();


    if (hasChocolate = true){
        String chocolate = "Add Chocolate to the coffee";
        return chocolate;
    }
    if (addCream.isChecked()){
        String cream = "Add Cream to the coffee";
        return cream;
    }


    EditText enterName = (EditText) findViewById(R.id.edit_text);
    Editable addName = enterName.getText();

    int price = calculatePrice();
    String priceMessage = createOrderSummary(addName, price, chocolate,        cream);
    displayMessage(priceMessage);
    return priceMessage;
}

/**  Calculates the price of the order.  */
private int calculatePrice() {

    return quantity * 5;
}


/** displays the number of coffee between the + and - buttons */
private void displayQuantity(int number) {
    TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view);
    quantityTextView.setText("" + number);
}
private String createOrderSummary(Editable enterName, int calculatePrice, boolean chocolate, boolean cream) {
    String priceMessage = "Name = " + enterName + "\nQuantity : " + quantity + "\n" + chocolate + "\n" + cream + "\nTotal: £ " + calculatePrice + "\nThank you!";
    return priceMessage;

}

public void increment(View view) {
    quantity = quantity + 1;
    displayQuantity(quantity);
}

public void decrement(View view) {
    quantity = quantity - 1;
    displayQuantity(quantity);
}




/**
 * This method displays the given text on the screen.
 */
private void displayMessage(String message) {
    TextView orderSummaryTextView = (TextView)   findViewById(R.id.order_summary_text_view);
    orderSummaryTextView.setText(message);
}




Laravel get value of checkbox

i have many checkboxes with this code

@foreach($camera_video as $video)
  <input type="checkbox" name="camera_video" value=""> <label></label>
@endforeach

now i would like to see which checkboxes the user have checked. I just need the id (value) to store. How is the best way to do this in laravel?




jQuery for loop for checkbox selection

I have three checkboxes which might be checked based on the requirement of the user. And I want them to select anyone without any, in particular, being required. But I want them to select at least one amongst the and want to achieve the same with jQuery, I have already done the validation on the backend but if someone can help me a way where jQuery can achieve the same with a for loop it would be great. Fiddle for the same

Below are the three checkboxes

HTML:

<div class="form-group">
    <div class="cols-sm-10">
        <p>Select tests </p>
        <label class="col-md-12" id="select-type">
          <div class="col-md-2" id="select-type">
            <input value="Test A" type="checkbox" name="app1" ><span class="radio-size"><span class="demo-select">&times;</span></span>
          </div>
        </label>
        <label class="col-md-12" id="select-type">
          <div class="col-md-2" id="select-type">
            <input value="Test B" type="checkbox" name="app1" ><span class="radio-size"><span class="demo-select">&times;</span></span>
          </div>
        </label>
        <label class="col-md-12" id="select-type">
          <div class="col-md-2" id="select-type">
            <input value="Test C" type="checkbox" name="app1" ><span class="radio-size"><span class="demo-select">&times;</span></span>
          </div>
        </label>
    </div>
</div>




Add values if checkboxes are checked - Javascript

I am a begginer in javascript and I have a set of checkbox inputs interchanging with a set of textbox inputs in my html form. The purpouse of a check box is to identify which texpoxes are printed and which are not.

Example:

<form>
<input type='checkbox' name='one'>
<input type="text" name="one"><br>
<input type='checkbox' name='two'>
<input type="text" name="two"><br>
<input type='checkbox' name='three'>
<input type="text" name="three"><br>
<input type='checkbox' name='four'>
<input type="text" name="four"><br>
</form>

so i need a small javascript example on what would be the best way to print only text from text boxes where the checkbox is checked?




How to get Text and Value of CheckBox with several way?

I already read the other article but still not solve it. I have check box that generate by :

$('#sel_div').append("<div style='margin-bottom:4px;margin-right:5px;float:left;width:80px;'><input type='checkbox' name=loc["+loc_id+"][] style='margin:2px;' value='"+myvalue+"' onClick='handler(this)'>"+description+"</div>");

The question is , how to get value of checkbox (myvalue) and text of checkbox (description) ?

What i have to do :

function handler(checkbox){
        var checkedValue = checkbox.value;
        alert(checkedValue);
        alert($('input[type=checkbox]:checked').next().val());
        alert($('input[type=checkbox]:checked').next().text());
}

The result :

checkedValue get correct value but the other alert shown blank.

Can anyone explain what wrong with the code ?

Thank you




Check and uncheck checkboxes after click one main checkbox in jQuery

This is not a duplicate of any question.I tried Stackoverflow answers but those are not helpful for me.

I have one Select All Checkbox.If it checked all other check boxes are checked, if I unchecked it all other check-boxes are unchecked.That's my task.

I did it and its working.but sometimes its not working properly. Please check my codes and give some idea to develop it.

HTML

<th width="10%" style="background-color: #cce5ff;"><input type="checkbox" id="<?php echo $user['user']->id; ?>" class="checkbox select_all user_<?php echo $user['user']->id; ?>" style="cursor: pointer;"></th>

<td width="10%">
    <input type="checkbox" id="view_<?php echo $folder->id; ?>_<?php echo $user['user']->id; ?>" class="is_check_v check_this_<?php echo $user['user']->id; ?>" value="view" <?php if(isset($user['permission'])){if(!empty($user_permissions) && $user_permissions->can_view==1){ echo 'checked';}else{echo '';}}?>  name="per">     

    <input type="hidden" id="h_view_<?php echo $folder->id; ?>_<?php echo $user['user']->id; ?>" name="view_permission[][<?php echo $folder->id; ?>][<?php echo $user['user']->id; ?>]" value="<?php if(!empty($user_permissions)){ echo $user_permissions->can_view;}else{ echo 0; } ?>">
            </td>
            <td width="10%">
                <input type="checkbox" id="edit_<?php echo $folder->id; ?>_<?php echo $user['user']->id; ?>" class="is_check_e check_this_<?php echo $user['user']->id; ?>" value="edit" <?php if(isset($user['permission'])){if(!empty($user_permissions) && $user_permissions->can_edit==1){ echo 'checked';}else{echo '';}}?> name="per">
                <input type="hidden" id="h_edit_<?php echo $folder->id; ?>_<?php echo $user['user']->id; ?>" name="edit_permission[][<?php echo $folder->id; ?>][<?php echo $user['user']->id; ?>]" value="<?php if(!empty($user_permissions)){ echo $user_permissions->can_edit;}else{ echo 0; } ?>">
            </td>
            <td width="7%">
                <input type="checkbox" id="delete_<?php echo $folder->id; ?>_<?php echo $user['user']->id; ?>" class="is_check_d check_this_<?php echo $user['user']->id; ?>" value="delete" <?php if(isset($user['permission'])){if( !empty($user_permissions) && $user_permissions->can_delete==1){ echo 'checked';}else{echo '';}}?> name="per">
                <input type="hidden" id="h_delete_<?php echo $folder->id; ?>_<?php echo $user['user']->id; ?>" name="delete_permission[][<?php echo $folder->id; ?>][<?php echo $user['user']->id; ?>]" value="<?php if(!empty($user_permissions)){ echo $user_permissions->can_delete;}else{ echo 0; } ?>">
            </td>

jQuery

$(".select_all").click(function () {

        user_id = $(this).attr('id');

        $.each($('.check_this_'+user_id),function(){
            $(this).prop("checked", $('.user_'+user_id).prop("checked"));                

            $(this).click(function(){
                $('.user_'+user_id).prop("checked", false);           
            });

        });

    });




Assign a variable a value if a checkbox is clicked within a form javascript

I'm trying to assign a variable a value as long as certain checkboxes are clicked. The code below works for what I need, but as soon as I sit it within a form, it breaks the function.

I think I'm missing something pretty simple, but for the life of me can't find out how to select a form value - also would anyone have advice on how to scale this for use with several checkboxes?

function cb3(checkbox) {
  if (checkbox.checked) {
    alert("function called!");
    $userChoice1 = 'value1';
  } else {
    $userChoice1 = '';
  }
}
<script src="http://ift.tt/1qRgvOJ"></script>
<input type="checkbox" id="cb3test" name="cb3" value="value1" onClick="cb3(this)">Value1

Thanks in advance, applogies if this is a duplicate, although I couldn't find a question with regards to forms.




how to send 'no' in form when checkbox isn't checked in wp

In contact form 7 plugin of wordpress, is it possible to send custom message to mail based on checkbox value. In my form I have, subscribe to newsletter checkbox. When user checks the checkbox, subscribe to newsletter is coming as 'Yes' in mail.Now I want to send subscribe to newsletter as 'No' when user doesn't check the checkbox.

Is it possible. I tried and am still searching for the answer in google but to no avail.Any help/suggestion is welcome. Thanks in advance.




lundi 30 janvier 2017

Two way binding for checkbox inside an accordion not workiing

In my angular 1.5 html5 application, I have an accordion group and inside it's body I have Couple of check-boxes. Since direct scope binding will not work inside accordion, I'm using ng-click event as attachedng-click instead of direct model binding.

This works as expected, I'm getting click events with correct value.

I have another reset button on screen, when user clicks this button I have to reset all filters including the checkbox inside the accordion. Even after I reset the model value to false, checkbox still shows as checked. I know this is because the binding is not there.

How can I update the checkbox value from javascript. Is there any angular way. I'm not a big fan of JQuery.

Regards, Nixon




MFC Rich Edit Control 2.0 receiving click event

I was hoping someone out there would help me with my predicament I ran into. Essentially I have a Checkbox and a RichEditControl next to each other. I want to be able to know when a user has clicked on my RichEditControl so i can send a message to my checkbox to flag it on and off.

At first i tried to overlay my checkbox with empty text to act as a "blank" background for my RichEditControl so i wouldn't have to worry about sending messages left and right. No matter what i tried the "blank" background would overlap the RichEditControl text and leave it completely blank.

I searched on here for some help and i found this which is exactly what I ran into. I understand what he is saying but don't have the knowledge to implement what they said.

Right now I'm playing around with EN_LINK to attempt to capture a message so i can tell my checkbox to flag itself.

BEGIN_MESSAGE_MAP(TempInit, CDialog)
ON_NOTIFY(EN_LINK, IDC_TempInitMsg, &TempInit::OnEnLinkTempinitmsg)
END_MESSAGE_MAP()

void TempInit::OnEnLinkTempinitmsg(NMHDR *pNMHDR, LRESULT *pResult)
{
ENLINK *pEnLink = reinterpret_cast<ENLINK *>(pNMHDR);
// TODO: Add your control notification handler code here
    // TODO: Add your control notification handler code here
    radioClicked = !radioClicked;
    if (radioClicked == true)
    {
        GetParent()->SendMessage(WM_MYRADIOCLICKED, CHECKENABLED, 0);
    }
    else
    {
        GetParent()->SendMessage(WM_MYRADIOCLICKED, CHECKDISABLED, 0);
    }
}
*pResult = 0;
}

I'm sorry in advance if this is totally the wrong way to go about this. I've been googling for a few hours and have come empty handed. If anyone has any other method please help me if possible. I can post more code if what i have above isn't enough.




VBA IF statement with Form Control (CheckBox)

I'm trying to create a check box using form control (not ActiveX) to make the formula bar appear/disappear. The problem is that when I check the button, the formula bar disappears - but when I uncheck the button, nothing happens (i.e. the formula bar doesn't appear again). Here's the code I have:

Sub FormulaBar2()

    If ActiveSheet.Shapes("CheckBox5").ControlFormat.Value = True Then
        Application.DisplayFormulaBar = True
    Else
        Application.DisplayFormulaBar = False
    End If

End Sub




Uncaught ReferenceError: lookup is not defined at HTMLButtonElement.onclick

I keep getting this syntax error on the browser. I am not sure what am I missing here.

Here is my javascript.

 function lookup() {
        var query = document.getElementById("sform").value;
        //   var res = PageMethods.lookupfromjs_Click(query, onSuccess, onError);
        var dttypeList;
        $('#Button1').click(function() {
            $('input[type=\"checkbox\"]').each(function(){
                dttypeList.push(this.name);
                alert( $.toJSON(dttypeList));
            });
        });​
    }

Here is the html

<button id="Button1" onclick="lookup()" type="button">Search</button>




Unchecked box using checkboxInput in Shiny

I am trying to get my Shiny app to do one of two things based on the checked status of a checkboxInput.

When the box is checked, I can get my code to work. However, I can't figure out how to make unchecking the box lead to a unique result.

How do I do this?

Below is a reproducible example. - In this example, unchecking the box leads to an error reading "argument is of length zero."

library(shiny)

ui <-  fluidPage(
  checkboxGroupInput(inputId = "test.check", label = "", choices = "Uncheck For 2", selected = "Uncheck For 2"),
  verbatimTextOutput(outputId = "test")
)

server <- function(input, output) {

  output$test <- renderPrint({
    if(input$test.check == "Uncheck For 2") {
      1
    } else {
      2
    }
  })


}

shinyApp(ui = ui, server = server)




How to disable cell on grid according to checkbox status extJs 6

I need to disable some cell according checkbox status changed. I add a listener on checkbox column:

listeners: {
    checkchange: function( me , rowIndex , checked , record , e , eOpts) {

    var row = me.getView().getRow(rowIndex);

    var columnIndex = Ext.getCmp('MyColumnIdToDisable').fullColumnIndex;

    Ext.get(row.childNodes[columnIndex]).setDisabled=!checked;
    }        
}

But this error is displayed:

Uncaught TypeError: Ext.get(...).setDisabled is not a function




How can I wrap checkbox form elements in CSS?

I am working on some code that presents a form with a number of checkboxes in a particular form. I would like to get the checkboxes to wrap to a second (and third, and fourth) line, but am having trouble doing so. At the moment, the checkboxes run straight off the page in a line without wrapping. I've researched a good bit and found some situations that are similar, but none of the solutions so far have worked.

There are 10 (or more) checkboxes, but for the sake of brevity I've listed only a few of them since listing all of them wouldn't really add to the conversation:

My CSS:

.add-to-cart .attribute label {
    display: inline;
    padding-right: 35px;
}
.add-to-cart .form-checkboxes{
    max-width: 600px;
    height: 300px;
    display: inline-flex;
}

.add-to-cart .attribute .form-item .form-type-checkbox {
    position: absolute;
    display: inline-block;
    width: 100%;
    height: 90px;
    background-color: #ddd;
    padding: 20px;
    margin: 10px;
    white-space: nowrap;
    text-align: center;
    vertical-align: middle;
    font: bold 10px verdana, arial, 'Raleway', sans-serif;
    font-style: italic;
}

My HTML/Code:

<div class="content">
<div class="add-to-cart">
    <form class="ajax-cart-submit-form" action="/this-product" method="post" id="uc-product-add-to-cart-form-7" accept-charset="UTF-8">
    <div class="attribute attribute-7 even">
        <div class="form-item form-type-checkboxes form-item-attributes-7">
            <label for="edit-attributes-7">Extras </label>
            <div id="edit-attributes-7" class="form-checkboxes">
                <div class="form-item form-type-checkbox form-item-attributes-7-49">
                    <input type="checkbox" id="edit-attributes-7-49" name="attributes[7][49]" value="49" class="form-checkbox" />
                    <label class="option" for="edit-attributes-7-49"> Blue </label>
                </div>
                <div class="form-item form-type-checkbox form-item-attributes-7-43">
                    <input type="checkbox" id="edit-attributes-7-43" name="attributes[7][43]" value="43" class="form-checkbox" />
                    <label class="option" for="edit-attributes-7-43"> Red </label>
                </div>
                <div class="form-item form-type-checkbox form-item-attributes-7-50">
                    <input type="checkbox" id="edit-attributes-7-50" name="attributes[7][50]" value="50" class="form-checkbox" />
                    <label class="option" for="edit-attributes-7-50"> Green </label>
                </div>
            </div>
        </div>
    </div>
</div>
</div>




How to clear checkboxes and set one checkbox in JIRA postfunction using Groovy with Adapatvist ScriptRunner

I have a Groovy script Post-Function using Adapatvist scriptRunner that creates sub tasks based on what checkboxes are checked on the parent issue during creation.

How do I clear all of those check boxes from the parent issue in a Post-Function and set the parent's checkbox selection to just one (different) check?




How to change datepicker options based on a checkbox?

I have a JqueryUI datepicker on which I only want dates 5-days-out (or more) to be available. This works fine for that...

     var dateToday = new Date(); 
        $( "#datepicker" ).datepicker({
        minDate: '+1w', // your min date
        beforeShowDay: $.datepicker.noWeekends // disable weekends
 });    

I also have a checkbox that, IF CHECKED, essentially overrides the minDate and makes the minDate available TODAY's date (rather than a week out):

<input type="checkbox" class="lessThanFiveDays" value="1" name="less-than-5-days" />I need this earlier than the standard 5 business days   

I'm struggling with where the checkbox checking JQuery needs to go and in what order. Also, do I just check if the box is checked, or does the altering of the datepicker params need to happen on a "change" event on the checkbox.

This below is wrong, but hopefully it helps illustrate how I'm confusing myself:

$( "#datepicker" ).datepicker({
minDate: '+1w', // your min date
beforeShowDay: $.datepicker.noWeekends // disable weekends*/
});
 $('.lessThanFiveDays').change(function() {
    if($(this).is(":checked")) {
        $( "#datepicker" ).datepicker({
        minDate: dateToday, // your min date
        beforeShowDay: $.datepicker.noWeekends // disable weekends*/
        });
    }




Calling jQuery code in razor block of code

I have a problem where I need to call jQuery code to fetch a value from an HTML element like following:

@using (Html.BeginForm("Login", "Home",new { Checked = $('#checkbox5').checked }, FormMethod.Post,new { @class = "form-horizontal", role = "form" }))
{  
@Html.AntiForgeryToken()  
}

Note that besides passing the entire model into my Login action I'm trying to pass an optional parameter named "Checked". This parameter basically states whether the "remember me" checkbox has been checked on the form or not.

The checkbox itself is not the one that .NET uses by default like:

@Html.CheckboxFor(somepropertyhere);

But instead a regular checkbox like this:

   <input id="checkbox5" type="checkbox">
     <label for="checkbox5">
     Remember me?
     </label>

How can I fetch this checkbox's value when passing it as an extra parameter besides my model?

So that my method in the end would look like:

Public ActionResult Login(bool Checked, LoginViewModel model)
{
// To have the checked value here now...
}

P.S. And I can't use Html.CheckboxFor for some reasons, but I don't wanna get too much into details since the question wouldn't make sense then (maybe it doensn't even now I'm not sure if this is doable what I'm trying to achieve).

Can someone help me out?




Checkbox in php contact form returns empty [duplicate]

This question already has an answer here:

I've read several posts on this issues but nothing i'm implimenting seems to solve my problem.

I have a working 'contact form' that I want to add a checkbox to. I've done all the necessary html to get the checkbox working, but for some reason the email it generates doesn't contain the checked boxes.

This is the section of html (i've only included the 'phone' form as well as the 'area' checkbox entry just for reference... this is on a bootstrap 3 site):

<div class="control-group">

                    <div class="controls ">                            

                        <label for="phone">YOUR PHONE</label><br>

                        <input type="text" name="phone" id="phone" required data-validation-required-message="Please enter your phone" />

                    </div>

                </div>



                <div class="control-group">

                    <div class="controls">

                        <label for="area">SERVING AREA</label>
                        <p class="form-sub">Please indicate the area(s) you would like to serve in<br></p>
<input type="checkbox" name="area[]" value="PA-Tech"><label>PA and Tech</label><br>
<input type="checkbox" name="area[]" value="Publicity-comms"><label>Publicity and comms</label><br>
<input type="checkbox" name="area[]" value="Youth"><label>Youth (current DBS certificate will be required)</label><br>
<input type="checkbox" name="area[]" value="Kids"><label>Kids (current DBS certificate will be required)</label><br>
<input type="checkbox" name="area[]" value="Creche"><label>Creche and toddlers (current DBS certificate will be required)</label><br>
<input type="checkbox" name="area[]" value="First-Aid"><label>First Aid</label><br>
<input type="checkbox" name="area[]" value="Bookshop"><label>Bookshop</label><br>
<input type="checkbox" name="area[]" value="Sport-Social"><label>Running sports and social events</label><br>
<input type="checkbox" name="area[]" value="Security"><label>Security and stewarding</label><br>
<input type="checkbox" name="area[]" value="Registration"><label>Registration, welcome and info desk</label><br>
<input type="checkbox" name="area[]" value="Parking"><label>Car parking</label><br>
<input type="checkbox" name="area[]" value="Health-Safety"><label>Health and Safety</label><br><br>
                    </div>
                </div>

Submitting the form calls a js function:

// CONTACT FORM FUNCTION

var contact_send = function(){
'use strict';
var name        = $("#name").val();
var age         = $("#age").val();
var email       = $("#email").val();
var phone       = $("#phone").val();
var area        = $("#area").val();
var experience  = $("#experience").val();
var elder       = $("#elder").val();
var type        = $("#type").val();

     if ( name=="" ){ alert("Name area is empty!"); $("#name").focus(); }

else if ( age=="" ){ alert("Age is empty!"); $("#age").focus(); }

else if ( email=="" ){ alert("Email address area is empty!"); $("#email").focus(); }

else if ( phone=="" ){ alert("Phone number area is empty!"); $("#phone").focus(); }

else if ( area=="" ){ alert("Serving area is empty! Please tick some serving areas"); $("#area").focus(); }

else if ( experience=="" ){ alert("Experience area is empty!"); $("#experience").focus(); }

else if ( elder=="" ){ alert("Elder Contact area is empty!"); $("#elder").focus(); }

else if ( type=="" ){ alert("Register type isn't selected!"); $("#type").focus(); }

else {

    $.post("contact.send7b.php", { name:name, email:email, age:age, phone:phone, area:area, experience:experience, elder:elder, type:type }, function( result ){

        if ( result=="SUCCESS" ){

            alert("Thank You! Your contact form has been sent. (You should receive a copy to the address you have provided, but check your spam/junk)");

            setTimeout(function(){

                $("#name").val("");

                $("#age").val("");

                $("#email").val("");

                $("#phone").val("");

                $("#area").val("");

                $("#experience").val("");

                $("#elder").val("");

                $("#type").val("");

            }, 3000);

        } else {

            alert("Your contact form isn't sent. Please check fields and try again.");

        }
    });
}

};

Then as you can see the js calls a php script to send the mail, here is the part that creates the message:

$mail->msgHTML("Application to Serve at Together 2017: ".
        $_POST["type"]."<br /><br /> Name: ".
        $_POST["name"].". <br />Email: ".
        $_POST["email"].". <br />Phone: ".
        $_POST["phone"].". <br />Age: ".
        $_POST["age"]."<br /><br />Areas Interested in serving: ".
        implode(",", $_POST["area"])."<br />Previous Experience: ".
        $_POST["experience"]."<br /><br />Contact details for Elder: ".
        $_POST["elder"]);

//send the message, check for errors

if (!$mail->send()) { echo "ERROR"; } else { echo "SUCCESS"; }

The form sends, and resets (apart from the checkboxes) but When the email arrives it just says this:

--

Phone: +277936747485. Age: 34

Areas Interested in serving: Previous Experience: 19 years in live sound

--

At one point it was returning 'PA and Tech' (the first checkbox) but it would do that even though that option was not checked.

I've tried changing the name="area" tired in the form to include name="area[]" as it is above, tried including id="area[1]" id="area[2]" etc but nothing ever seems to work...




How to work with checkbox list in lotusscript?

I'm developing a lotus notes application. I wonder how to check/uncheck and enable/disable individual checkbox options from the checkbox list. This is how i did a work around to check it somehow:

Dim CheckListInitiator As String CheckListInitiator = doc.CheckListInitiator(0) ''get the checked items text in a variable.

''append the content of the required checkbox to the list. This will check it.

If CheckListInitiator = "" Then ''if nothing checked, means the list is empty. CheckListInitiator = "Allotment Approval attached"
Else ''the list has one or more options checked, so append the content. CheckListInitiator = CheckListInitiator + "; Allotment Approval attached"
End If

I'm not sure if this is the right way of doing this. Also I'm still unable to enable and disable individual items from the list.

Can anybody help on how to do this?

Thanks,

baburman




Unable to get value from checkbox bootstrap toggle in PHP

Html and PHP :

<input type="checkbox"  name="get_ckvalue" data-toggle="toggle"  data-on="Available" data-off="Day Off" value="true" />

<?php
echo $_POST['get_ckvalue']; // Give null as a output 
?>

I am using checkbox button with bootstrap toggle and i want to get the value (true/false) , but i am getting null as a result . i don't know what is wrong . How can i get the value from checkbox . i am new to html and bootstrap . Thank in advanced . its just the fragment of code . i have successfully submitted the POST .




Logical checkboxes in treelist

I've got a treelist with checkboxes. This treelist holds many items of the same type, distributed across several layers.

Now if the user unchecks one item, all items of the same type shall be unchecked as well. Can you give me advice how to implement this? Would the observer pattern be a possible solution? And how is this to use here?




Symfony form many-to-many with many-to-many

I have an entity that has a manyToMany relation with category. Category has also a manyToMany relation with sub-category.

In a formType, in the buildForm method, I'm trying to do something like that with checkbox :

My entity form

[ ] category_1  
  [ ] sub-category_1_1  
  [X] sub-category_1_2  
  [ ] sub-category_1_3  
[X] category_2  
  [X] sub-category_2_1  
  [ ] sub-category_2_2  
  [ ] sub-category_2_3  

Has someone already tried this ? Better, someone has a solution ? :D




dimanche 29 janvier 2017

ASP MVC 5 - keep @html.checkbox state after page reload after clicking "submit button"

I created a page that I can search the store detail via entity framework I added a column of checkbox in the table. I would like to keep the checkbox "checked=True" after I submit via the search button.

What would be the recommend way to achieve that ?

I tried following method, but the checkbox get "unchecked" after I click submit 1. http://ift.tt/25ms3xQ

View as following :

@using (Html.BeginForm())
{
<p>
    Find by name: @Html.TextBox("SearchString") 
    <input type="submit"  name ="StoreIndexButton" value="Search" />
</p>
}
<table class="table" id="displayresult">

@foreach (var item in Model) {
<tr>
    <td>
        @Html.DisplayFor(modelItem => item.sname)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.smarket)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.sstatus)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.soper)
    </td>
    <td>
        @Html.DisplayFor(modelItem => item.sowneroperator)
    </td>
    <td>
        @Html.ActionLink("Details", "Details", new { id=item.store1 })
    </td>
    <td>
        @Html.CheckBox("selected",new { value = item.store1,     id="selected"+item.store1.ToString() })
    </td>
</tr>
}

</table>

Controller as following :

public ActionResult Index(string StoreIndexButton,string searchString)
    {
        var AR_stores = (from m in db.stores
                         select m).Take(10);
        string[] selectedList = Request.Form.GetValues("selected");
        if (!String.IsNullOrEmpty(searchString) && StoreIndexButton =="Search")
            {
                    AR_stores = (from m in db.stores
                                 select m).Where(s =>   s.sname.Contains(searchString));
                }
            return View(AR_stores);    
    }

Model as following :

 using System;
using System.Collections.Generic;

public partial class store
{
    public int store1 { get; set; }
    public string sname { get; set; }
    public string smarket { get; set; }
    public string sstatus { get; set; }
    public string soper { get; set; }
    public string sowneroperator { get; set; } 
}




How to change background of Android checkBox?

I have android checkBox and the default background is transparent, I want it to be white so I use style:

<style name="BrandedCheckBox" parent="AppTheme">
    <item name="colorAccent">@color/cyan</item>
    <item name="colorControlNormal">@color/text_gray</item>
    <item name="colorControlActivated">@color/cyan</item>
</style>

and set checkBox theme:

<CheckBox
    android:id="@+id/check_payable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_gravity="center"
    android:theme="@style/BrandedCheckBox"/>

But the result is this: enter image description here But I want it to to be like this: enter image description here

Can any one help me on this?




Bind multiple checkbox in page from database table or Store Procedure in asp.net web forms?

I have number of checkbox in a page, and want to bind those from database table together, how can i do this? thanks




checkbox state not working perfectly in listview

I have one listview in which I have list item that is a order card. In each list item I have one listview that shows menu items of card. I have 2 adapters one for setting order card that has been called from activity and another adapter for setting menu items that have been called through order page adapter. Now problem is that when I click arrow button that is in order card adapter then it will display all menu items otherwise only two. I have checkbox related to each menu item when I checked the check box and then click on arrow button to expand or collapse the list then state of checkbox changed. I am not able to solve this problem. Please help me.

//code for setting ordercard adapter from activity

 adapter= new CustomAdapeter_AllPage(dataModels,getActivity(),AllPage.this);
                    list.setAdapter(adapter);

// code for custom adapter

     if (vv == null) {
        viewHolder = new ViewHolder();
        LayoutInflater inflater = LayoutInflater.from(mContext);
        vv = inflater.inflate(R.layout.adapter_listview_pending_card, parent, false);


   viewHolder.listview = (ListView) vv.findViewById(R.id.menulist);
        setListViewHeightBasedOnChildren(viewHolder.listview, false);

// setting menu adapter in card adapter

  viewHolder.listview.setAdapter(new MenuAdapterForAll(mContext, menuModels));
            setListViewHeightBasedOnChildren(viewHolder.listview, false);

}

// code for arrow button in card adapter

 viewHolder.showhide.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {


            isExpand = !isExpand;
            if (isExpand == true) {


                setListViewHeightBasedOnChildren(viewHolder.listview, true);

                viewHolder.showhide.setImageResource(R.drawable.blackarrrowup);
                String com = data.getOrder_comments();
                Log.e("TAG", "all comment: " + com);
                if ((com == null)) {
                    viewHolder.comments.setVisibility(View.GONE);


                } else {
                    viewHolder.comments.setText(data.getOrder_comments());
                    viewHolder.comments.setVisibility(View.VISIBLE);
                }
                  notifyDataSetChanged();

            } else {

                viewHolder.showhide.setImageResource(R.drawable.blackarrow);
                viewHolder.comments.setVisibility(View.GONE);
                setListViewHeightBasedOnChildren(viewHolder.listview, false);
                notifyDataSetChanged();
            }

// setting listview height in card adapter for menu item

   public static void setListViewHeightBasedOnChildren(ListView listView, Boolean expand) {
    ListAdapter listAdapter = listView.getAdapter();
    if (listAdapter == null)
        return;

    int itemcount = 0;
     if (expand == true)
    {
         itemcount = listAdapter.getCount();
    }
    else
     {
         itemcount = 2;
     }


    int desiredWidth = View.MeasureSpec.makeMeasureSpec(listView.getWidth(), View.MeasureSpec.UNSPECIFIED);
    int totalHeight = 0;
    View view = null;
    for (int i = 0; i < itemcount; i++) {
        view = listAdapter.getView(i, view, listView);
        if (i == 0)
            view.setLayoutParams(new ViewGroup.LayoutParams(desiredWidth, ViewGroup.LayoutParams.WRAP_CONTENT));

        view.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
        totalHeight += view.getMeasuredHeight();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
   // if (expand == true)
    {
        params.height = totalHeight + (listView.getDividerHeight() * (itemcount - 1));
        Log.e("TAG", "setListViewHeightBasedOnChildren:1 " + listView.getDividerHeight());
    }
 //        else {
 //            params.height = totalHeight + (listView.getDividerHeight() *     (2 - 1));
 //            Log.e("TAG", "setListViewHeightBasedOnChildren:2 " + params.height);
  //        }
    listView.setLayoutParams(params);
}

// code for menu adapter for check box

     String complete_menu = data.getMenuitem_complete();


    if(complete_menu.equals("1"))
    {
        viewHolder.cbmenu.setChecked(true);
    }

    if(checkBoxState[position])
    {
        viewHolder.cbmenu.setChecked(true);
    }
    else
    {
        viewHolder.cbmenu.setChecked(false);
    }


    // viewHolder.cbmenu.setChecked(checkBoxState[position]);
    viewHolder.cbmenu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
         @Override
         public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            if(viewHolder.cbmenu.isChecked() == true)
            {
                checkBoxState[position] = true;
                flag = 1;
            }
            else
            {
                checkBoxState[position] = false;
                flag = 0;
            }

            callChangeStatusService(flag,data.getMenuitem_id(),   data.getMenuitem_orderid());
        }
    });

// this calls web service when check or unchecked checkbox

Thanks in advance.




Angular2 checkbox with primeng fails

I am using angular2 cli and this is the way i have setup my form

In the component

export class UsersAddComponent implements OnInit {

 ngOnInit() {
    this.userForm = this._formBuilder.group({
      role: ['', [Validators.required]],
      others: this._formBuilder.array([])  //for adding multipe form inputs
    });

   this.addNewUser();

  }

  initAddress() {
     return this._formBuilder.group({     
       sendcred: [''],  //checkbox needs no validation in my logic
        needs_reset: [''], // ''
        .....other fields here
    });
 }


  addNewUser() {  //this is called whenever add new user button is clicked
     const control = <FormArray>this.userForm.controls['others'];
     const addrCtrl = this.initAddress();
     control.push(addrCtrl);
   }

In the html template am using primeng checkbox like this

  <p-checkbox formControlName="needs_reset" label="User has to set password" 
   (onChange)="Onpwdchange()"></p-checkbox>

  <p-checkbox formControlName="sendcred" name="send cred"  label="Send user
 login credentials " (onChange)="Oncredchange()"></p-checkbox>

The methods onpwdchange() and oncredchange() just have a console.log("clicked")

Whenever i check the checkboxes am getting an error

this.model.push is not a function  //i havent implemented push method anywhere

Ive checked on This primeng2 issue but they advice use of disableDeprecatedForms() and provideForms() which are not available in angular2 cli

How do i solve this issue




How to set dispaly text for ComboBox (checkable) in Qt

I follow these to create checkable combobox

ComboBox of CheckBoxes?

http://ift.tt/2jtuUP4

However when I do a this->Model->clear() then add items, the combobox text (the text combobox displays before user clicking anything) goes blank. The items will still show and are checkable when click on the combobox. I suspect the clear() remove the header and causes this, however I try setHorizontalHeaderLabels etc but I still can't set the combobox text. What am I missing?




How can I use checkboxes and ExpandableListView?

I have an ExpandableListView, each category contains items with their respective checkboxes, but when I collapse a category or scroll the activity, the selection goes away. How can I keep my checkboxes checked for future use? And how can I use them?

Here's my item layout

<LinearLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="16dp"
>

<ImageView
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:src="@mipmap/ic_launcher"
    android:layout_gravity="center_vertical"
    />

<TextView
    android:id="@+id/itemTv"
    android:textSize="14sp"
    tools:text="item"
    android:paddingLeft="8dp"
    android:layout_gravity="center_vertical"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>

<CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/itemCB" />

here's my adapter

public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context context;
private List<String> listDataHeader;
private HashMap<String, List<Item>> listHashMap;

public ExpandableListAdapter (Context context, List<String> listDataHeader, HashMap<String, List<Item>> listHashMap){
    this.context = context;
    this.listDataHeader = listDataHeader;
    this.listHashMap = listHashMap;
}

@Override
public int getGroupCount() {
    return listDataHeader.size();   //cantidad de grupos
}

@Override
public int getChildrenCount(int groupPosition) {
    return listHashMap.get(listDataHeader.get(groupPosition)).size();   //tamaño de grupo
}

@Override
public Object getGroup(int groupPosition) {
    return listDataHeader.get(groupPosition);
}

@Override
public Object getChild(int groupPosition, int childPosition) {
    return listHashMap.get(listDataHeader.get(groupPosition)).get(childPosition);
}

@Override
public long getGroupId(int groupPosition) {
    return groupPosition;
}

@Override
public long getChildId(int groupPosition, int childPosition) {
    return childPosition;
}

@Override
public boolean hasStableIds() {
    return false;
}

@Override  
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    View view = convertView;
    String headerTitle = (String) getGroup(groupPosition);
    if(view == null){  
        LayoutInflater inflater = (LayoutInflater)this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.listgroup_header,null);
    }
    TextView lblListHeader = (TextView)view.findViewById(R.id.listgroupHeaderTv);
    lblListHeader.setTypeface(null, Typeface.BOLD); 
    lblListHeader.setText(headerTitle);
    return view;
}

@Override 
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

    View view = convertView;
    ItemHolder holder = null;

    if(view == null){
        LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.list_item,null);
        holder = new ItemtHolder();
        holder.itemName = (TextView) view.findViewById(R.id.itemTv);
        holder.itemCheckBox = (CheckBox) view.findViewById(R.id.itemCB);
        //holder.itemCheckBox.setOnCheckedChangeListener((MainActivity) context);
        view.setTag(holder);
    }
    else{
        holder = (ItemHolder) view.getTag();

    }
    Item currentItem = (Item) getChild(groupPosition, childPosition);
    holder.itemName.setText(currentItem.getItemName());
    holder.itemCheckBox.setChecked(currentItem.isChecked());
    holder.itemCheckBox.setTag(currentItem);

    return view;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
    return true;
}

private static class ItemHolder{
    public TextView itemName;
    public CheckBox itemCheckBox;
}

}

I know it has to be something with the Holder but I don't know what, and I don't know how to use the checkListener and the expandableLV




How to send multiple checkbox group values through ajax?

I am having three group of check boxes as follows:

echo '<input type="checkbox" name="metal[]" value="'.$value.'" id="'.$value.'" onclick="return submitForm()" ><label for="'.$value.'"></label>';
echo '<input type="checkbox" name="shape[]" value="'.$value.'" id="'.$value.'" onclick="return submitForm()"><label for="'.$value.'" ></label>';
echo '<input type="checkbox" name="type[]" value="'.$value.'" id="'.$value.'" onclick="return submitForm()"><label for="'.$value.'" ></label>';

All coming from database. I want to send these values through ajax. My current code is:

function submitForm() {
var form = document.myform;

var dataString = $(form).serialize();
$.ajax({
type:'POST',
url:'carousel.php',
data: dataString,
success: function(data){
    $('#myResponse').html(data);


}
});
return false;
}</script>

This function is sending only single value to carousel.php. I further want to process data and show result according to the checked values. Also on clicking another checkbox, previous checkbox values is lost. I found above code on google and very new to ajax. Please help.




Repeater nested into a Repeater causing CheckBox.OnCheckedChanged event trigger unexpectingly

I am working on an ASP WebForm.

The page contains a father ASP:Repeater. This Repeater's children themselves contain a Repeater that contains a collection of CheckBoxes. I need to add an event on these CheckBoxes OnCheckChange so whenever we click one of the CheckBoxes, it unchecks all of the other checkboxes. I could use a RadioButton, but using CheckBoxes has other advantages for me that are out of this subject so I do not want to use radio buttons.

That would theorically work fine just like this:

    <ItemTemplate>

        ...

        <ASP:Repeater id="ChildRepeater" runat="server" OnItemDataBound="MyRepeater_ItemDataBound">
            <ItemTemplate>
                <asp:CheckBox id="MyCB" runat="server" OnCheckedChanged="MyCB_CheckedChanged" AutoPostBack="true" />
            </ItemTemplate>
        </ASP:Repeater>

    </ItemTemplate>

</ASP:Repeater>

I want that, when I click on a CB, the following method triggers:

  protected void MyCB_CheckedChanged(object sender, EventArgs e)
    {
       UncheckallOtherCheckBoxes();
    }

I must have some binding issues that cause all scenarios not to work.

If I data bind my FatherContainer into Page_Load on first load only:

 protected void Page_Load(object sender, EventArgs e)
        {
          if (!IsPostBack)
            {
                MyRepeater.DataSource=DS;
                MyRepeater.DataBind();
            }
        }

the data binding is fine on first load and I can see all my beloved checkboxes. But when I click any CheckBox, the page reloads, FatherContainer does not re-bind, the checkboxes cease to exist and their event method never triggers.

So I take it that I have to DataBind on every page load that way:

protected void Page_Load(object sender, EventArgs e)
    {
     //   if (!IsPostBack)
        {
            MyRepeater.DataSource=DS;
            MyRepeater.DataBind();
        }
    }

If I do that, I get some unexpected results.

Let's say my first ItemTemplate contains 3 CheckBoxes.

On first load, everything is fine again.

If I click on the second CB, it does reload, FatherContainer rebinds into Page_Load, and then MyCB_CheckedChanged is fired with sender = my second CB. That is normal so far.

Now if I click on the third CB, the page reloads again, FatherContainer rebinds again. MyCB_CheckedChanged is fired twice!!! First time with SENDER = SECOND CB again!! and second time with 3rd CB.

And if I click CB2 again, on page reload, MyCB_CheckedChanged fires with sender = CB3 (and not CB2).

It looks that MyCB_CheckedChanged does not trigger when a CB status changes but when a CB is checked after Page_Load.

I tried to databind into Page_Init instead : same results.

And if I dataBind into OnPreRender, MyCB_CheckedChanged is never triggered at all!!

So what shoud I do to have MyCB_CheckedChanged being fired only for the CB that was just checked or unchecked?

Thx in advance.




Why do checkboxes have setSelectionRange property and how to test for it?

I am pretty sure I used to test check boxes for the setSelectionRange property and they did not have one. But that seems to have changed in some browsers (tested Firefox and Chrome).

I used to do a check for the setSelectionRange property before making a selection like this:

if (el.setSelectionRange) {
  el.setSelectionRange(0, 9999);
}

However, since check boxes appear to have the setSelectionRange property this throws an error.

So how do I test now for whether a selection can be made or not?

Here is also a fiddle:

http://ift.tt/2jK27a0




samedi 28 janvier 2017

DataTable checkbox coloum select all and remeber with pagination

I want to remember the marked checkboxes in my dataTable. currently it works when I checked individual check boxes. How to do same with toggle checkbox ? please advice

view

<th><input  name="select_all" class="groupCheckBoxAll" type="checkbox"/></th>
<td><input type="checkbox" class="groupCheckBox" name="emails[]" value=' + id + ' ></td>

js

here is my datatable rowcallback function

    "rowCallback": function(row, data, dataIndex) {
        var rowId = data['id'];
        if ($.inArray(rowId, checkedArray) !== -1) {
            $(row).find('input[type="checkbox"]').prop('checked', true);
        }
    }

$(document).on('change','.groupCheckBox',function(){
    if ($(this).is(':checked')) {
        checkedArray.push($(this).val());
    } else {
        var index = checkedArray.indexOf($(this).val());

        if (index >= 0) {
            checkedArray.splice(index, 1);
        }
    }


});

pls advice




Reactjs - unable to put a condition/limitation on checkbox select option

I am trying to use checkboxes in react and the condition is to use only 2 checkboxes at a time and when we use third, it should disable all others till we uncheck another one - so to make total checked max at 2. This is to compare only two results at once.

I am able to get two checkboxes but when i do the third, its disabling all the checkboxes. I am not sure where am i going wrong over here. Any ideas or suggestions would be appreciated. Thanks.

 var App = React.createClass({

    getInitialState: function () {

        return {

            resultcheck: this.props.resultcheck || false,
            disabled: this.props.disabled || false,
            enabled: []

        };
    },
    onResultChoose: function(id,count,event){
        var enabled = this.state.enabled;
        // console.log(id);
        // console.log(count);
        this.setState({resultcheck: this.state[event.target.checked]});
        console.log(this.state[event.target.checked]);
        if(event.target.checked){
            enabled.push(count);
        }
        else{
            enabled.pop();
        }
        //console.log(enabled);
        if(enabled.length == 3){
            this.setState({disabled: false);
            enabled.pop();
        }
        this.setState({enabled:enabled});
    },                           

    render: function() {

        var count = 0;

        return (
                <Grommet.App centered={false}>
                    <Split flex="right">

                        <Split flex="left">
                            <Box direction="column" justify="center" pad=>

                                <List selectable={true}>

                                    {this.state.execList.map((row) => {

                                        return (
                                            <ListItem justify="between" >
                                                <span>
                                                    <Timestamp value={new Date(row.startTime)} />
                                                    {" for " + row.runTime + " secs"}
                                                </span>
                                                <span>
                                            <CheckBox id={count} label='compare' checked={this.state.resultcheck} disabled={this.state.disabled} onChange={this.onResultChoose.bind(this,row.executionId,count)}/>
                                                </span>
                                            </ListItem>
                                        )
                                    })}
                                </List>

                            </Box>


                        </Split>
                    </Split>
                </Grommet.App>
        );
    }
});

var element = document.getElementById('content');
ReactDOM.render(React.createElement(App), element);

till 2nd check box

after clicking 3rd check box




Validation of Checkboxes to other Checkboxes

I am looking to Validate a form or checkboxes, but the validation has some weird constraints. The checkboxes are not required for the form to be valid. So I am attaching a picture of what the form looks like to help in figuring out the best way to validate this. Picture of the form

If I am checking a checkbox to the left of the label, then the previous checkbox to the left of the label would need to be checked for it to be valid. So as in the picture if I want to check the left checkbox for Artisan then the left checkbox for Expert must be checked.

Now if I am checking a checkbox to the right of the label, then the checkbox to the left of the label must be checked along with the previous checkbox to the right of the label. Again referring to the picture, if I want to check the right checkbox for Artisan then the left checkbox for Artisan must be checked, and the right checkbox for Expert must be checked.

Lastly for the two bottom checkboxes, only one of them at a time can be checked. But that is if and only if the checkbox to the left of Expert for that label is checked. So if we look at the form, if Scholar's Guild is checked, Weaponsmith's Guild cannot be checked. And the Expert in Scholar above must be checked.

Does anyone have any thoughts on how this might be accomplished?




Checkbox array isn't being sent from form to PHP

Only the name and email are being sent, and not the array. Here is the form :

<form class="form-horizontal" name="sentMessage" id="contactForm">
                    <fieldset>

                        <!-- Form Name -->
                        <legend>Préinscription</legend>

                        <!-- Text input-->
                        <div class="form-group">
                          <label class="col-md-4 control-label" for="text">Nom</label>  
                          <div class="col-md-4">
                            <input id="name" name="Préinscription" type="text" placeholder="Veuillez entrer votre nom." class="form-control input-md" required="">

                          </div>
                        </div>

                        <div class="form-group">
                          <label class="col-md-4 control-label" for="email">Email</label>  
                          <div class="col-md-4">
                          <input id="email" name="Préinscription" type="email" placeholder="Veuillez entrer votre adresse mail." class="form-control input-md" required="">

                          </div>
                        </div>

                        <!-- Multiple Checkboxes -->
                        <div class="form-group">
                          <label class="col-md-4 control-label" for="checkboxes">Samedi 5 août</label>
                          <div class="col-md-4">
                          <div class="checkbox">
                            <label for="checkboxes-0">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes5-0" value="1">
                              Saint amour
                            </label>
                            </div>
                          <div class="checkbox">
                            <label for="checkboxes-1">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes5-1" value="2">
                              Polisse
                            </label>
                            </div>
                          </div>
                        </div>

                        <!-- Multiple Checkboxes -->
                        <div class="form-group">
                          <label class="col-md-4 control-label" for="checkboxes">Dimanche 6 août</label>
                          <div class="col-md-4">
                          <div class="checkbox">
                            <label for="checkboxes-0">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes6-0" value="1">
                              La vie d'Adèle
                            </label>
                            </div>
                          <div class="checkbox">
                            <label for="checkboxes-1">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes6-1" value="2">
                              De rouille et d'os
                            </label>
                            </div>
                          </div>
                        </div>

                        <!-- Multiple Checkboxes -->
                        <div class="form-group">
                          <label class="col-md-4 control-label" for="checkboxes">Lundi 7 août</label>
                          <div class="col-md-4">
                          <div class="checkbox">
                            <label for="checkboxes-0">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes7-0" value="1">
                              Bang gang
                            </label>
                            </div>
                          <div class="checkbox">
                            <label for="checkboxes-1">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes7-1" value="2">
                              Médecin de campagne
                            </label>
                            </div>
                          <div class="checkbox">
                            <label for="checkboxes-2">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes7-2" value="3">
                              Les innocentes
                            </label>
                            </div>
                          </div>
                        </div>

                        <!-- Multiple Checkboxes -->
                        <div class="form-group">
                          <label class="col-md-4 control-label" for="checkboxes">Mardi 8 août</label>
                          <div class="col-md-4">
                          <div class="checkbox">
                            <label for="checkboxes-0">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes8-0" value="1">
                              La loi du marché
                            </label>
                            </div>
                          <div class="checkbox">
                            <label for="checkboxes-1">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes8-1" value="2">
                              Les malheurs de sophie
                            </label>
                            </div>
                          <div class="checkbox">
                            <label for="checkboxes-2">
                              <input type="checkbox" name="checkboxes[]" id="checkboxes8-2" value="3">
                              Ma loute
                            </label>
                            </div>
                          </div>
                        </div>

                        <br/>
                        <!-- Button -->
                        <div id="success"></div>
                        <div class="form-group">
                          <label class="col-md-4 control-label" for="singlebutton"></label>
                          <div class="col-md-4">
                            <button id="singlebutton" name="singlebutton" class="btn btn-default" type="submit">Envoyer</button>
                          </div>
                        </div>

                    </fieldset>
                </form>

And here is the PHP that goes with it :

<?php
// Check for empty fields
if(empty($_POST['name'])      ||
   empty($_POST['email'])     ||
   !filter_var($_POST['email'],FILTER_VALIDATE_EMAIL))
   {
   echo "No arguments Provided!";
   return false;
   }

$name = strip_tags(htmlspecialchars($_POST['name']));
$email_address = strip_tags(htmlspecialchars($_POST['email']));

$filmsSelectionner= 'Aucun';
if(isset($_POST['checkboxes']) && is_array($_POST['checkboxes']) && count($_POST['checkboxes']) > 0){
    $filmsSelectionner= implode(', ', $_POST['checkboxes']);
}

// Create the email and send the message
$to = 'islam20088@hotmail.com';
$email_subject = "Nouvel preinscription de la part de $name";
$email_body = "Vous avez reçu une nouvelle préinscription depuis votre forumalaire sur le site de Les Films de Plein Air.\n\n"."Voici les détails:\n\nNom: $name\n\nEmail: $email_address\n\nFilms à laquel il y sera: $filmsSelectionner\n\n";
$headers = "From: noreply@yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$headers .= "Reply-To: $email_address";   
mail($to,$email_subject,$email_body,$headers);
return true;         
?>

And in my email, both the text and the email are being sent. Also, the $filmsSelectionner is being sent as well and it's value is Aucun. That means the problem is coming from the if condition. I need help, I'm a beginner ! :)




Can't get checkboxes to update correctly (php, mysql)

Sorry if this has already been addressed before but I have searched for a solution here and elsewhere and cannot seem to find out why this isn't working.

So I have a form that pulls data from a DB. The fields are input text boxes with check boxes along the side so that a user can update the title, URL and select whether each one is to be active or inactive.

The problem is a bit hard to explain but it only seems to update one row. What am I missing or doing wrong here?

Thanks for any help! Siafu

So, rssfeeds.php:

echo "<form name='rssfeedupdate' action='rssfeeds_update.php' method='POST'>
<table width='100%' border='0'>";

// SELECT DATA FROM DB
$result_rss = @mysql_query("SELECT * FROM rss_feeds ORDER BY status DESC, title") or die(mysql_error());
$count = mysql_num_rows($result_rss);
while ($row = mysql_fetch_array($result_rss)) {

$id = $row['id'];
$title = $row['title'];
$feedurl = $row['feed'];
$status = $row['status'];

    echo "<tr>
    <td valign='top'>
        $id <input type='text' name='title[]' value='$title' size='20%'></input>
    </td>

    <td valign='top'>
        <input type='text' name='feedurl[]' value='$feedurl' size='60%'></input>
    </td>

    <td valign='top' align='center'>";
        if($status == 'on') {
            $checked = "checked";
        } else { 
            $checked = "";
        }
        echo "
        <input type='checkbox' name='status[]' $checked></input>";

    echo "</td>
    </tr>

    <tr>
    <td valign='top' align='center' colspan='4'>
        <br><hr><br>
    </td>
    </tr>";

<input type='hidden' name='id[]' value='$id'></input>   
}

echo "</table>
<input type='hidden' name='count' value='$count'></input>
<table width='100%' border='0'>
<tr>
<td valign='top' align='right' colspan='4'>
<input type='submit' name='submit' value='Update Feeds'></input>
</td>
</tr>
</table>
</form>";

rssfeeds_update.php:

        // LETS GET INFO FROM rssfeeds.php
        if(isset($_POST['id'])) {
            $id = $_POST['id'];
        }
        if(isset($_POST['count'])) {
            $count = $_POST['count'];
        }
        if(isset($_POST['title'])) {
            $title = $_POST['title'];
        }
        if(isset($_POST['feedurl'])) {
            $feedurl = $_POST['feedurl'];
        }
        if(isset($_POST['status'])) {
            $status = $_POST['status'];
        }

        for($i=0; $i<$count; $i++) {
            echo "<table width='100%' border='0'>
            <tr>
            <td valign='top' width='5%'>
                $id[$i]
            </td>
            <td valign='top' width='20%'>
                $title[$i]
            </td>
            <td valign='top' width='60%'>
                $feedurl[$i]
            </td>
            <td valign='top' width='10%'>
                $status[$i]
            </td>
            </tr>
            </table>";


            $Update_Feeds = "UPDATE rss_feeds SET title='$title[$i]', feed='$feedurl[$i]', status='$status[$i]' WHERE id='$id[$i]'";
        }


        if (!mysql_query($Update_Feeds, $link)) {
            die('<br><br>Error: ' . mysql_error());
        } else {
            echo "<br><br>RSS feeds updated successfully! <a href='rssfeeds.php'>Go Back</a>";
        }




Alphabetical order not working when loading external checkboxes

I'm pulling in some checkboxes from an external HTML file to a tab container, and after they load I want them sorted alphabetically. The sorting works fine when the checkboxes load internally, but when loaded externally the sorting fails. Don't know if this is a delay issue or other error. I've tried delay(), setTimeout(), and hints from related posts but nothing works. Any ideas anyone? Fiddle: http://ift.tt/2kdTw2s

http://ift.tt/20g0BuL
http://ift.tt/2dsPzTA


<ul class="tabs-nav">
 <li class="tab-active"><a href="#Container" rel="nofollow">Countries</a></li>
 <li class=""><a href="#blank2" rel="nofollow">Year</a></li>
 <li class=""><a href="#blank3" rel="nofollow">Products</a></li>
</ul>

<div class="TabContainerClass">

<div id="Container">
<div id="CountryID" class="CountryClass">

<!--
<label class="myEuropeCountries"><input type="checkbox"  id="UN400" value="Poland" />Poland</label>
<label class="myEuropeCountries"><input type="checkbox"  id="UN500" value="Macedonia" />Macedonia</label>
<label class="myEuropeCountries"><input type="checkbox"  id="UN196" value="Cyprus" />Cyprus</label>
<label class="myEuropeCountries"><input type="checkbox"  id="UN100" value="Bulgaria" />Bulgaria</label>
<label class="myEuropeCountries"><input type="checkbox"  id="UN40" value="Austria" />Austria</label>
-->
</div>
</div>

</div>




// Loading from external file & sorting alphabetically

$(function() {
  $.get('http://ift.tt/2ke08xG', function(data) {
var $data = $(data);
$("#CountryID").html($data.find('#CountryStore_ws'));
  });

  function sortByText(a, b) {
    return $.trim($(a).text()) > $.trim($(b).text()) ? 1 : -1;
  }

  var li = $(".CountryClass").children("label").detach().sort(sortByText);
  $(".CountryClass").append(li)
});



// ================
$(function() {
  $('.tabs-nav a').on('click', function(event) {
    event.preventDefault();

    $('.tab-active').removeClass('tab-active');
    $(this).parent().addClass('tab-active');
    $('.TabContainerClass > div').hide();
    $($(this).attr('href')).fadeIn(300)
  });
  $('.tabs-nav a:first').trigger('click');
});





.tabs-nav {
list-style: none;
margin: 0;
padding: 0;
}

.tabs-nav .tab-active a {
cursor: default;
}

.tabs-nav a {
border-width: 0px 1px 1px 0px;
border-style: solid;
display: block;
height: 32px;
text-align: center;
width: 160px;
}

.tabs-nav li {
float: left;
}

.TabContainerClass {
width: 480px;
height: 110px;
border: 1px solid orange;
clear: both;
position: relative;
background: white;
}

.CountryClass {
position: absolute;
width: 468px;
height: 80px;
}




change value if the checkbox is checked reactjs

In this code I have a list of checkbox and next to each checkbox a message that says selected / unselected I am now needing that when selecting each checkbox change that message depending on the state of the checbox

Checkbox is selected = 'selected '
Checkbox is not selected = 'unselected '

and the codepen http://ift.tt/2jAhcgH thanks




vendredi 27 janvier 2017

compare two arrays reactjs

I have this code: in reactjs http://ift.tt/2kbzkxY

1- list an array, when mapping I send each item a checkbox
2- I have another array that I still do not have
3- I need to compare the two arrays and if there is an element of both arrays 

equal the checkbox that is repeated in list is active example Array1 [1,2,3] Array2 [2] The checkbox "2" appears cheked




Adding an array of values to an existing array

I've got a foreach where I create an array out of id's, based on the submitted selected checkboxes from my form (which are `checkbox[$id]. So I end up with:

Checkboxes

Where 1, 2 and 3 are the submitted id's from the form. So far so good.

Now I also have an input field amount[$id]in my form. When selecting a checkbox, I can enter an amount for that row and submit the results. I need to add the values of amount to my array if id's. My end result should look like this:

[1 => ['amount' => '10'], 2 => ['amount' => '12'], 3 => ['amount' => '5'] // And so on

I tried merging, and array_push, but I seem to be doing it wrong, since I cannot figure it out. Any pointers?




How to check multiple checkboxes in Javascript

I've just started to learn JavaScript and have run into a issue trying to get multiple checkboxes to work.

I am trying to calculate the cost of a product based on the options checked. However, my script is automatically assuming that all the boxes have been checked.

What is wrong with this code? Sorry if its a basic question but I have been banging my head for hours now.

function cal() {

    var selectionOne = 0;
    var selectionTwo = 0;
    var selectionThree = 0;
    var total = 0;


    if (document.getElementById("1").checked = true ){
        selectionOne = 25;
    }

    if (document.getElementById("2").checked = true ){
        selectionTwo = 50;
    }

    if (document.getElementById("3").checked = true ){
        selectionThree = 100;
    }

    total = selectionOne + selectionTwo + selectionThree;

    alert ("Your total is £" + total);

}

HTML

<html>
  <head>
    <title>Basic Pricing Script</title>
  </head>
  <body>
    <script src="script.js"></script>

    <p>Please select which options you want from the list</p>

    <form name="priceoptions">

      <input type="checkbox" id="1" name="big" value="big"> Big Prints<br>
      <input type="checkbox" id="2" name="medium" value="medium" > Medium Prints<br>
      <input type="checkbox" id="3" name="small" value="small"  > Small Prints<br>
      <input type="submit" id="button" value="Submit" onclick="cal()">

    </form>

  </body>
</html>




Bind a checkbox in a listview to a class variable?

I would like to be able to get and set the state of a checkbox in a listview. I would like to either be able to automatically update MyListItems[row].myCheckedValue when the box is clicked by somehow binding in xaml (I know very little about binding) or to be able to loop through each list item by row and access the checkboxes in C#. I don't know how to approach either. I'm just starting out with WPF.

I Could also use Checked and Unchecked events, but I don't know how to retrieve the row of the list item the checkbox is in.

<ListView Name="listView">
   <ListView.ItemTemplate>
      <DataTemplate>
         <CheckBox x:Name="checkBox" Checked="itsChecked" Unchecked="itsUnchecked"/>
      </DataTemplate>
   </ListView.ItemTemplate>
</ListView>


public List<myListItem> MyListItems;
...
listView.ItemsSource = MyListItems;
...
public class myListItem {
   public bool myCheckedValue;
}


private void getCheckedItems() {
   //Loop through listview rows and get checkbox state
   //???
}


private void itsChecked(object sender, RoutedEventArgs e) {
   //How can I get the row this checkbox is in??
}




VBA - Refer to CheckBox from the cell address

I am looping through few rows and I need to know if the CheckBox in each row is "Checked" or not, but I don't know the name of the CheckBox. The below code is just to illustrate the problem:

Sub Checkboxes()

Dim ws As Worksheet
Set ws = Sheets("Input Data")
Dim Switch As Boolean

For i = 4 To 8
    Switch = ws.Cells(11, i).CheckboxValue
    MsgBox Switch
Next i


End Sub

To create the checkboxes I did the following:

  1. Create a CheckBox
  2. Place it in a cell
  3. Copy below in the same column



AngularJS: How can I select multiple checkboxes using shift and mouse click?

Is it possible to use shift and mouse click to select multiple elements on a table using AngularJS?

I have a table in which the first column is a checkbox and I would like to use SHIFT key and mouse click in order to select multiple rows continuously and can do things like delete, edit them etc.

Example by steps:

  1. Click on 1st row's checkbox.
  2. Holding down SHIFT key.
  3. Click on 10th row's checkbox.

Result: the first 10th rows will be selected.

Does anyone know how this can be done using AngularJS?




Parent input show/hide checkboxes

I have a page with 3 hidden areas and 3 checkboxes to show/hide the corresponding area. When the checkbox is ticked the area is shown. Also, each hidden area has its own checkbox within the span.

Required: When an area is shown/unhidden and the checkbox within that area is also ticked it will show "area-x". Area-x will only show though when all unhidden spans checkboxes are ticked.

$(function() {
    Areas();
});

function Areas() {

  $('span[data-name="Comms engineering"]').hide();
  $('span[data-name="Comms engineering - review and sign off"]').hide();
  $('span[data-name="Control engineering"]').hide();
  $('span[data-name="Control engineering - review and sign off"]').hide();
  $('span[data-name="Protection engineering"]').hide();
  $('span[data-name="Protection engineering - review and sign off"]').hide();



   var isCOMMS =  $('input[name="Attributes.SFRs.AreasOfResponsibilities"][data-savedvalue="Comms Engineering"]:checked').length > 0;
   var isCONTROL = $('input[name="Attributes.SFRs.AreasOfResponsibilities"][data-savedvalue="Control engineering"]:checked').length > 0;
   var isPROTECT =  $('input[name="Attributes.SFRs.AreasOfResponsibilities"][data-savedvalue="Protection engineering"]:checked').length > 0;



if(isCOMMS) {
  $('span[data-name="Comms engineering"]').show();
  $('span[data-name="Comms engineering - review and sign off"]').show();
}

if(isCONTROL) {
  $('span[data-name="Control engineering"]').show();
  $('span[data-name="Control engineering - review and sign off"]').show();
}

if(isPROTECT) {
  $('span[data-name="Protection engineering"]').show();
  $('span[data-name="Protection engineering - review and sign off"]').show();
}

};




In viewpager, checkbox state loss on swipe. what is logic behind this scenario

I have viewpager which has multiple fragments.

 <LinearLayout xmlns:android="http://ift.tt/nIICcg"

android:layout_width="match_parent"
android:layout_height="match_parent">
 <CheckBox android:layout_width="match_parent"
           android:layout_height="match_parent"
           android:text="Do you need recurring" />
  <RadioGroup android:id="@+id/rdgrpEnd"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_margin="@dimen/most_most_most_min_margin"
              android:gravity="left|start"
              android:orientation="vertical">

                        <RadioButton
                            android:id="@+id/rdbtnNever"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="0.3"
                            android:padding="@dimen/min_margin"
                            android:text="Never " />

                        <RadioButton
                            android:id="@+id/rdbtnAfter"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="0.3"
                            android:padding="@dimen/min_margin"
                            android:text="After" />
                        <RadioButton
                            android:id="@+id/rdbtnOn"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_weight="0.3"
                            android:padding="@dimen/min_margin"
                            android:text="After" />
    </RadioGroup>

 </LinearLayout>

with this i got no error on this. My doubt is, My viewpager has 15 fragments and which doesn't have setOffscreenPageLimit() function. I I checked both check box and radio button. I swiped to last fragment. ex: 15th fragment.now i am back to first fragment which i checked on before swipe to 15th fragment. Here, CheckBox lost it's state.(Here unchecked) but radio button has it's state(Here checked state) .what is the logic behind this.




How do I make a specific checkbox usable/clickable (not read-only) whilst a form is opened with acFormReadOnly in Microsoft Access?

We've got a checkbox on a form that we'd like to be able to check/uncheck even whilst the form is opened as read-only (it's a sales/product form and when an order has been invoiced, we want to prevent changes).

I know I could add a command button in its place and even make that button look like it's a checkbox with some images, or even set up a key combination to be used instead of the checkbox, but first I'd like to know if it's possible to simply exclude one checkbox from being read-only on a read-only form.




jeudi 26 janvier 2017

Select all checkboxes React

Hi guys so I have this module

import React, { Component } from 'react'
import EmailListItem from './EmailListItem'
import { createContainer } from 'meteor/react-meteor-data'
import { Emails } from '../../../../../imports/collections/emails/Emails'

class EmailList extends Component {
  constructor (props) {
    super(props)
    this.state = {
      selectedEmails: new Set(),
      checked: false
    }
  }

  handleSelectedEmails (selectedEmail, checked) {
    let selectedEmails = this.state.selectedEmails
    if (checked) {
      selectedEmails.add(selectedEmail)
    } else {
      selectedEmails.delete(selectedEmail)
    }
    this.setState({selectedEmails})
    console.log('selectedEmails', this.state.selectedEmails)
  }
  removeSelected () {
    const selectedEmails = Array.from(this.state.selectedEmails)
    Meteor.call('emails.remove', selectedEmails, (err, result) => {
      if (err) console.log(err)
      if (result) console.log(result)
    })
  }
  checkedClick () {
    this.setState({checked: !this.state.checked})
    console.log('chcekedClick')
  }
  renderList () {
    console.log(this.props)
    return this.props.emails.map(email => {
      console.log(email)
      const { name, opr, ctr, _id } = email
      const createdAt = email.createdAt.toDateString()
      const link = `/dashboard/emailpreview/${_id}`
      return (
        <EmailListItem
          selecetedAllEmails={this.state.checked}
          handleSelectedEmails={this.handleSelectedEmails.bind(this)}
          name={name}
          createdAt={createdAt}
          opr={opr}
          ctr={ctr}
          link={link}
          key={email._id}
          id={email._id} />
        )
    })
  }
  render () {
    // TODO: make checks with state
    return (
      <div className="email_list">
        <table>
          <thead>
            <tr>
              <td><input onChange={this.checkedClick.bind(this)} type="checkbox" checked={this.state.checked} /></td>
              <td>Title<button onClick={this.removeSelected.bind(this)} className="btn btn-danger">Remove</button></td>
              <td>Dates</td>
              <td>Open Rates</td>
              <td>CTA</td>
            </tr>
          </thead>
          <tbody>
            {this.renderList()}
          </tbody>
        </table>

      </div>
  )
  }
}

export default createContainer(() => {
  Meteor.subscribe('emails')
  return { emails: Emails.find({}).fetch() }
}, EmailList)

And it renders this module

import React, { Component } from 'react'
import { Link } from 'react-router'

class EmailListItem extends Component {
  constructor (props) {
    super(props)
    this.state = {
      checked: false
    }
  }

  checkedClick () {
    this.setState({checked: !this.state.checked})
    console.log('chcekedClick')
  }

  componentDidUpdate () {
    console.log('componentDidUpdate')
    const { myCheckbox } = this.refs
    console.log('myCheckbox', myCheckbox)
    console.log('myCheckbox.name', myCheckbox.name)
    console.log('myCheckbox.checked', myCheckbox.checked)
    if (this.props.selecetedAllEmails) {
      console.log('componentDidUpdate IF')
      this.checkedClick()
      this.props.handleSelectedEmails(myCheckbox.name, myCheckbox.checked)
    }
  }
  render () {
    console.log('_id', this.props.id)
    return (
      <tr>
        <td><input ref="myCheckbox"
          onChange={(event) => {
            this.checkedClick()
            this.props.handleSelectedEmails(event.target.name, event.target.checked)
          }}
          checked={this.state.checked}
          type="checkbox" name={this.props.id} /></td>
        <td><Link to={this.props.link}>{this.props.name}</Link></td>
        <td>{this.props.createdAt}</td>
        <td>Open Rates</td>
        <td>CTA</td>
      </tr>
    )
  }
}

export default EmailListItem

As you can see for each email item I have a checkbox. I can select a few checkboxes and click that remove button which will call remove my selected items. Now in the top I have a checkbox which should select all the checkboxes. My solution to this was to store the global checkbox checked and pass it as a prop to all the items. Then in the items I perform a check on componentDidUpdate and if the global checkbox is selected then I check that item as well. But this results in an infinite loop. What would be the best solution here , please? Thank you all in advance!