mardi 31 juillet 2018

Javascript - cannot dynamically create checked checkboxes

I have the following function that dynamically creates a bunch of checkboxes:

var drawGroups = function(){
  var groups = document.getElementById("groups"); //groups element is a div
  groups.innerHTML = "";

  //groupList is an array containing strings
  for(var i in groupList){
    var groupName = groupList[i];

    var cb = document.createElement('input');
    cb.type = "checkbox";
    cb.checked = true; //this seems to do nothing
    groups.appendChild(cb);

    groups.innerHTML += groupName + "<br/>"
  }
}

Everything I read indicates cb.checked = true should check the checkbox, but it doesn't seem to do anything. How can I create the checkboxes in a checked state?




Exclude materialize css for some specific checkbox

I want to exclude materialize css for some items in my view. Eg: i dont want to display materialize styles to check box under table. It causes problems with my internal jquery library. Please check attached image. I gave below html content in my table > td. I want to display this as browser default checkbox.

In my application i am using http://materializecss.com

<div class="checkbox">
    <input type="checkbox" class="filled-in dt-checkboxes">
    <label></label>
</div>

My table with checkbox




about to store multiple values of child checkbox related to parent checkbox, data is store only one time

when i store services and activity then services and activity value store multiple times in database, i also use implode instead of foreach but that time first service and first activity stored,the following image describe idea about what i exactly want

<form method='post' id='userform' action='savecheckbox.php'> <tr>
<td>Trouble Type</td>
<br>
<td>
 <input type='checkbox' name='servicevar[]' value='1'>tds<br>    <br>

<input type='checkbox' name='activityvar[]' value='1'>Return<br>
<input type='checkbox' name='activityvar[]' value='2'>Filling<br>
<br>


 <input type='checkbox' name='servicevar[]' value='2'>Gst<br>    <br>
<td>

<input type='checkbox' name='activityvar[]' value='1'>Return<br>
<input type='checkbox' name='activityvar[]' value='2'>Filling<br>
<br>

<input type='checkbox' name='servicevar[]' value='3'>vat<br>    <br>
<td>

<input type='checkbox' name='activityvar[]' value='1'>Return<br>
<input type='checkbox' name='activityvar[]' value='2'>Filling<br>
<br>
</td> </tr> </table> <input type='submit' name="submit" class='buttons'> 

<?php 
if(isset($_POST['submit']))
{
$activity = $_POST['activityvar']; 
$service = $_POST['servicevar'];


foreach ($service as $key => $servicevalue) {
    foreach($activity as $key=>$activityvalue)
    {
        $query = "insert into serviceacitivitymap(service_id,activity_id)values('$servicevalue','$activityvalue')";
        $insert_row=$conn->query($query) or die ($conn->error.__LINE__);

    }



}

}

?>




activities related to services display properly

I want to store related activities of services

<form method='post' id='userform' action='arrayvalue.php'> <tr>
<td>Trouble Type</td>
<br>
<td>
 <input type='checkbox' name='servicevar[]' value='tds'>tds<br>    <br>

<input type='checkbox' name='activityvar[]' value='One'>Return<br>
<input type='checkbox' name='activityvar[]' value='Two'>Filling<br>
<br>


 <input type='checkbox' name='servicevar[]' value='Gst'>Gst<br>    <br>
<td>

<input type='checkbox' name='activityvar[]' value='One'>Return<br>
<input type='checkbox' name='activityvar[]' value='Two'>Filling<br>
<br>
</td> </tr> </table> <input type='submit' name="submit" class='buttons'> 

     <?php if(isset($_POST[submit]) {
                     $activity = $_POST['activityvar']; 
                     $service = $_POST['servicevar'];

    foreach ($service as $key => $value) {
            echo ($value);
             echo "<br>";

    foreach ($activity as $key => $value) {
            echo ($value);
            echo "<br>";
            }
          }
       }

MY OUTPUT:

  • tds

    • one
    • two
    • one
    • two
  • Gst

    • one
    • two
    • one
    • two

Expected Output:

  • tds
    • one
    • two
  • Gst
    • one
    • two

Thanksss...




lundi 30 juillet 2018

How can I Display rows in database with checkbox infront of Each row and store the data which are selected into the database?

Im creating a website where there is a operation of student batch making. There will be 4 students in the batch and there will be a Lecturer Head for each batch. I Want to show the student detail rows and select 4 students to a batch. Not Getting how to do the thing.

My code looks like this

<?php include ('connect.php');
$query = mysql_query("select * from student") or die(mysql_error());
    while ($row = mysql_fetch_array($query)) {
          $id = $row['rollno'];                                 
?>
<tr class="warning">
      <td><?php echo $row['rollno']; ?></td> 
      <td><?php echo $row['name']; ?></td>                                            
      <td><?php echo $row['email']; ?></td> 
      <td><input type="checkbox" name="checkroll" value="$row['rollno']" id="checkbox"></td>   




PHP JavaScript Handling Checkbox values to add to shopping cart

I am trying to add the (Demo: Handling Checkbox Group) functionality shown in this website to my movie booking website. My initial value is $0.50 booking fee. But it doesnt seem to be responding when I click the checkbox. I'm hoping a fresh pair of eyes might help spot errors. Also, I'm a super beginner and JavaScript is my Kryptonite.

// check boxes containing ticket price and seat information

                      echo "<td> <form method=\"post\"action=\"seats.php\"><input type="
                  . "\"hidden\" name=\"performanceSeat\" value=\"". $row['RowNumber'] . "\">
                <input type=\"checkbox\" name=\"performancePrice\" value=". $row['CalculatedPrice'] ." />
                     </form>
</td>



                 "</tr>";

           }


                echo "</table>";

           }



           else {
               echo "0 results";
            }
           $conn->close();

           ?>



              //Calculated Price should add on here when checkbox is ticked
              <p id="totalPrice">
        <label>Total: $ <input type="text" name="total" class="num" size="6" value="0.00" readonly="readonly" /></label>
    </p>





    <form method="post" action="book.php"> Enter Email address: <input type="text" name="email">
    <input type="hidden" name ="sell_item_id" value="$_GET[iten_id]"/>
    <button type="submit" value="submit"> Add to cart </button>
    <button type="submit" value="submit" onclick="function()"> Total up </button>
</form>


    <script>
   document.getElementById('performancePrice').onclick = function() {
    // access properties using this keyword
    if ( this.RowNumber ) {
        // if checked ...
        alert( this.CalculatedPrice);
    } else {
        echo "nothing ticked"; 
    }
}; 

             // call onload or in script segment below form
        function attachCheckboxHandlers() {
            // get reference to element containing toppings checkboxes
            var el = document.getElementById('performancePrice');

            // get reference to input elements in toppings container element
            var tops = el.getElementsByTagName('performanceSeat');

            // assign updateTotal function to onclick property of each checkbox
            for (var i=0, len=tops.length; i<len; i++) {
                if ( tops[i].type === 'checkbox' ) {
                    tops[i].onclick = updateTotal;
                }
            }
        }


// called onclick of toppings checkboxes
function updateTotal(e) {
    // 'this' is reference to checkbox clicked on
    var form = this.form;

    // get current value in total text box, using parseFloat since it is a string
    var val = parseFloat( form.elements['total'].value );

    // if check box is checked, add its value to val, otherwise subtract it
    if ( this.performancePrince ) {
        val += parseFloat(this.CalculatedPrice);
    } else {
        val -= parseFloat(this.CalculatedPrice);
    }

    // format val with correct number of decimal places
    // and use it to update value of total text box
    form.elements['total'].value = formatDecimal(val);
}

// format val to n number of decimal places
// modified version of Danny Goodman's (JS Bible)
function formatDecimal(val, n) {
    n = n || 2;
    var str = "" + Math.round ( parseFloat(val) * Math.pow(10, n) );
    while (str.length <= n) {
        str = "0" + str;
    }
    var pt = str.length - n;
    return str.slice(0,pt) + "." + str.slice(pt);
}

// in script segment below form
attachCheckboxHandlers();


   </script> 




How to use checkbox in GroupView of expandablelistview Android

I see lot of tutorial about how to create an Expandablelistview but I can't find any one to show checkbox in a GroupView.

So I have a question How Can I do it?

Notice : I try it but after adding checkbox , my Expandablelistview don't expand.




MS-Access Check box IF statements

How would i add a check("chk3") that will be ticked when ("Customer order Number") field has been inputted. when an order number is entered, then the check box will tick..

i also would like to know if it is possible that When the value field ("Value") is under £10,000 then the check box ("chk2") will tick. if it is over £10,000 then it will not tick

enter image description here




Checkbox angular

Hi how can append checkbox type to display data after select type in angular 5

enter image description here




How to remove undefined checkboxes generated by ng-repeat with modulo operation?

I have the following code (see below), it creates from a given list multiple checkboxes, by using ng-if="$index % 3 == 0", I get 3 columns of checkboxes.

<div ng-controller="TestController" class="container">
    <div ng-repeat="item in items" ng-if="$index % 3 == 0" class="row">
        <div class="col-xs-4">
            <input type="checkbox" ng-model="items[$index].id">&nbsp;
            <span></span>
        </div>
        <div class="col-xs-4">
            <input type="checkbox" ng-model="items[$index+1].id">&nbsp;
            <span></span>
        </div>
        <div class="col-xs-4">
            <input type="checkbox" ng-model="items[$index+2].id">&nbsp;
            <span></span>
        </div>
    </div>
</div>

var app = angular.module('app', [ ]);
app.controller('TestController', ['$scope', function($scope) {

     $scope.items = [
    {id:0, name:"1/4 Mile"},
    {id:1, name:"1/2 Mile"},
    {id:2, name:"1 Mile"},
    {id:3, name:"2 Mile"},
    {id:4, name:"3 Mile"},
    {id:5, name:"4 Mile"},
    {id:6, name:"5 Mile"}
  ];
}]);

jsfiddle

The problem is, that if the number of items in the list is uneven, I get extra checkboxes that are blank/undefined. How can I avoid this?




simultaneously check and uncheck checkboxes

Using jquery how do i check and uncheck checkbox2 when checking and unchecking checkbox1?

<div>
    <input class="checkboxes" id="checkbox1" name="checkboxgroup" type="checkbox" value="First checkbox">
    <label for="checkbox1">First checkbox</label>
  </div>
  <div>
    <input class="checkboxes" id="checkbox2" name="checkboxgroup" type="checkbox" value="Second checkbox">
    <label for="checkbox2">Second checkbox</label>
  </div>
  <div>
    <input class="checkboxes" id="checkbox3" name="checkboxgroup" type="checkbox" value="Third checkbox">
    <label for="checkbox3">Third checkbox</label>
  </div>




dimanche 29 juillet 2018

How to circumvent id selectors in a checkbox hack?

I've posted about this project before. Twice, actually. And while the answers have helped me to better understand my situation, they haven't really been applicable to my situation. I blame myself because I was posting a skeletal version of the final code which didn't fully illustrate what I needed to accomplish.

Essentially: I need to integrate a relatively simple checkbox hack into a CMS, but the CMS strips id selectors. Hence, code that ought to look something like this:

<input type="checkbox" name="thisisaname" id="thisisanid"><label class="thisisanid" for="thisisanid">Type 1</label>

...ends up like this:

<input type="checkbox" name="thisisaname"><label class="thisisanid" for="thisisanid">Type 1</label>

Predictably, this breaks everything, and ostensibly any adaptation appears to be impossible. There is no CMS-specific alternative like ClientID=. Neither jQuery nor JavaScript are available to me (they're also stripped out by the CMS).

It's a case of something being extraordinarily simple to do, but being constrained by a CMS that multiplies the difficulty to the point where I'm uncertain if it's even possible. I am not a CSS maven. I know it only as much as I need to do these little projects for a few friends, and I apologize for posting about this yet again, but it's driving me crazy not knowing if this is something which ought to be shelved.

This is the code. Obviously, it's sloppy and it isn't in its fully-styled form, but it's close enough that I think it's a better example than what I've posted in the past:

#basesurround {
  background: #000000cc;
  margin: 0 auto;
  width: 75%;
}

.information-wrap { display:flex; vertical-align:top;} 
.information-wrap aside { background: #00000066; vertical-align: top; flex: 1 1 250px; min-width: 150px; padding: 0; max-width: 200px; }
.information-wrap main { vertical-align: top; display: flex; flex-direction: row; flex-wrap: wrap; width: 85%; justify-content: center; padding: 0 0 25px 25px; }

.information-wrap label { background: #000000cc; width: 100%; display: inline-block; border-bottom: 1px solid #000000; color: #9FC3C9; text-transform: capitalize; font-weight: 100; font-size: 11px; letter-spacing: 1px; cursor: pointer; transition: all 0.7s ease; position: relative; padding: 10px 10px 10px 30px; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; word-break: break-word; line-height: 125%; }
.information-wrap label:after { content: ""; width: 25px; height: 100%; position: absolute; left: 0; top: 0; background: #000000; filter: contrast(85%); }

.information-wrap details { position: relative; }

.information-wrap details summary::-webkit-details-marker { display: none; }

.information-wrap details summary::before { content: ""; position: absolute; left: 0; background: ; width: 1.5em; height: 1.5em; transition: transform 0.1s linear;}

.information-wrap summary { width: 100%; padding: 20px; padding-left: 25px; border-bottom: 1px solid #000000; background: #9FC3C9; font-family: Proxima; font-weight: 100; text-transform: uppercase; letter-spacing: 2px; color: #000000; -webkit-transition: all 1s ease; transition: all 1s ease; }

.information-wrap summary:hover { color: #ffffff4a; }

.information-wrap summary:focus {outline: none;}

.information-wrap details[open] > summary { background: #000000; filter: contrast(85%); color: #ffffff; }

.information-wrap details[open] > summary ~ * { animation: open 1s ease; }
.information-wrap details[open] summary:before {transform: rotate(90deg);}



.infocard { flex: 0 0 32.3%; display: inline-block; vertical-align: top; font-family: Proxima, Arial, Helvetica, Sans-Serif; position: relative; margin: .5%; align-items: center; justify-content: center; overflow: hidden; color: #000000; text-align: center; line-height: 160%; background-color: #141414; height: 300px; min-width: 300px; -webkit-box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); -moz-box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); -ms-box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); -webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; border-radius: 5px; min-width:250px;  border: 1px solid #000000;}

.infocard figure { border: 10px solid #DADCDB; margin: 10px 10px; padding: 0; display: inline-block; position: relative;}
.infocard figure img { display: block; height: auto; max-width: 100%; } 
.infocard figcaption { color: #000000; font: 400 18px/26px Proxima, Arial, Helvetica, Sans-Serif; padding: .2em 0; position: absolute; bottom: 0; text-align: center; width: 100%; }
.infocard figcaption span { font-size: 14px; color: #ffffff }
.infocard:last-of-type {margin-bottom: 200px;}

.infocard .icons { top: -7px; position: relative; color:#ffffff}


.information-wrap input { display: none; }
input:checked ~ main .infocard { display: none; }


        /* INFOCARD TYPE LABELS & CHECK CONTROLS */


                /* TYPE SET #1 */


#infotypeone_cont:checked ~ aside .infotypeone_cont,
#infotypetwo_cont:checked ~ aside .infotypetwo_cont,
#infotypethree_cont:checked ~ aside .infotypethree_cont,
#infotypefour_cont:checked ~ aside .infotypefour_cont,
#infotypefive_cont:checked ~ aside .infotypefive_cont
{ background: #000000; filter: contrast(85%); }

#infotypeone_cont:checked ~ main .infotypeone,
#infotypetwo_cont:checked ~ main .infotypetwo,
#infotypethree_cont:checked ~ main .infotypethree,
#infotypefour_cont:checked ~ main .infotypefour,
#infotypefive_cont:checked ~ main .infotypefive
{display: inline-block;}


                /* TYPE SET #2 */


#factiontypeone_cont:checked ~ aside .factiontypeone_cont,
#factiontypetwo_cont:checked ~ aside .factiontypetwo_cont,
#factiontypethree_cont:checked ~ aside .factiontypethree_cont,
#factiontypefour_cont:checked ~ aside .factiontypefour_cont,
#factiontypefive_cont:checked ~ aside .factiontypefive_cont
{ background: #000000; filter: contrast(85%); }

#factiontypeone_cont:checked ~ main .factiontypeone,
#factiontypetwo_cont:checked ~ main .factiontypetwo,
#factiontypethree_cont:checked ~ main .factiontypethree,
#factiontypefour_cont:checked ~ main .factiontypefour,
#factiontypefive_cont:checked ~ main .factiontypefive
{display: inline-block;}





        /* TYPE COLORS #1 */


.infotypeone {background-color: #ff00004d;}
.infotypetwo {background-color: #0076ff4d;}
.infotypethree {background-color: #ffac004d;}
.infotypefour {background-color: #ff00fc4d;}
.infotypefive {background-color: #d800004d;}







        /* INFORMATION CARDS */


.infocard * { -webkit-box-sizing: border-box; box-sizing: border-box; -webkit-transition: all 0.25s ease; transition: all 0.25s ease; }

.infocard .background { width: 100%; vertical-align: top; opacity: 0.2; -webkit-filter: grayscale(100%) blur(10px); filter: grayscale(100%) blur(10px); -webkit-transition: all 2s ease; transition: all 2s ease; }

.infocard figcaption { width: 100%; padding: 15px 25px; position: absolute; left: 0; top: 50%; }

figure.infocard img { display: inline;}

figure.infocard .profile {border-radius: 50%; position: absolute; bottom: 50%; left: 50%; max-width: 100px; opacity: 1; box-shadow: 3px 3px 20px rgba(0, 0, 0, 0.5); border: 2px solid rgba(255, 255, 255, 0.5); -webkit-transform: translate(-50%, 0%); transform: translate(-50%, 0%); }

figure.infocard img.profile { height: 100px; width: 100px; }

figure.infocard h3 { line-height: 160%; margin: 0 0 5px; font-weight: 100; font-family: Proxima, Arial, Helvetica, Sans-Serif; text-transform: uppercase; text-indent: 0px; }
figure.infocard h3 a { text-decoration: none; letter-spacing: .3em; color: #9FC3C9cc; line-height: 18px; font-size: 15px; -webkit-transition: all 1s ease; transition: all 1s ease; }
figure.infocard h3 a:hover {opacity: .3; }
figure.infocard h3 span a, figure.infocard h3 span { font-size: 8px; opacity: 0.75; letter-spacing: 2px; display: inline-block; line-height: 10px; }

figure.infocard i { padding: 10px 5px; display: inline-block; font-size: 32px; color: #ffffff; text-align: center; opacity: 0.65;}
figure.infocard a {text-decoration: none; background-size: 0;}
figure.infocard i:hover {opacity: 1; -webkit-transition: all 0.35s ease; transition: all 0.35s ease; }
figure.infocard:hover .background, figure.infocard.hover .background {-webkit-transform: scale(1.3);transform: scale(1.3);}
<div id="basesurround">
<form>
<div class="information-wrap">



<!--- BEGIN INFORMATION CONTROLLER :: CHECKBOX --->



  <input type="checkbox" name="cont" id="infotypeone_cont">
  <input type="checkbox" name="cont" id="infotypetwo_cont">
  <input type="checkbox" name="cont" id="infotypethree_cont">
  <input type="checkbox" name="cont" id="infotypefour_cont">
  <input type="checkbox" name="cont" id="infotypefive_cont">

  <input type="checkbox" name="cont" id="factiontypeone_cont">
  <input type="checkbox" name="cont" id="factiontypetwo_cont">
  <input type="checkbox" name="cont" id="factiontypethree_cont">
  <input type="checkbox" name="cont" id="factiontypefour_cont">
  <input type="checkbox" name="cont" id="factiontypefive_cont">  

<!--- END INFORMATION CONTROLLER :: CHECKBOX --->



  <aside>
    


<!--- BEGIN INFORMATION CONTROLLER :: LABELS --->



    <details><summary>
      

      SUBMENU TITLE
     
 
     </summary>

      
      <label class="infotypeone_cont" for="infotypeone_cont">Check 1</label>
      <label class="infotypetwo_cont" for="infotypetwo_cont">Check 2</label>
      <label class="infotypethree_cont" for="infotypethree_cont">Check 3</label>
      <label class="infotypefour_cont" for="infotypefour_cont">Check 4</label>
      <label class="infotypefive_cont" for="infotypefive_cont">Check 5</label>


    </details>

<!--- END INFORMATION CONTROLLER :: LABELS --->

<!--- BEGIN INFORMATION CONTROLLER --->

    <details><summary>
      

      SUBMENU TITLE
     
 
     </summary>

      
      <label class="factiontypeone_cont" for="factiontypeone_cont">Faction 1</label>
      <label class="factiontypetwo_cont" for="factiontypetwo_cont">Faction 2</label>
      <label class="factiontypethree_cont" for="factiontypethree_cont">Faction 3</label>
      <label class="factiontypefour_cont" for="factiontypefour_cont">Faction 4</label>
      <label class="factiontypefive_cont" for="factiontypefive_cont">Faction 5</label>


    </details>
<!--- END INFORMATION CONTROLLER --->
    
  </aside>
  
  <main>

        <!---  BEGIN INFORMATION CARD --->
<figure class="infocard infotypeone factiontypeone">

<img src="ICON" class="background"/>
<img src="ICON" class="profile"/>


<figcaption> <h3>


<a href="#">TITLE</a>


<br><span>

SUBTITLE ● 

<a href="#">MAIN LINK</a> <br>

INFO #2 | INFO #3

</span></h3><div class="icons">

                        <a href="PROFILEURL"><i class="ion-ios-person-outline"></i></a>
                        <a href="DROPBOXURL"><i class="ion-ios-email-outline"></i></a>
                        <a href="#"><i class="ion-ios-location-outline"></i></a>

</div></figcaption></figure>
        <!---  END INFORMATION CARD --->

        <!---  BEGIN INFORMATION CARD --->
<figure class="infocard infotypetwo factiontypetwo">

<img src="ICON" class="background"/>
<img src="ICON" class="profile"/>


<figcaption> <h3>


<a href="#">TITLE</a>


<br><span>

SUBTITLE ● 

<a href="#">MAIN LINK</a> <br>

INFO #2 | INFO #3

</span></h3><div class="icons">

                        <a href="PROFILEURL"><i class="ion-ios-person-outline"></i></a>
                        <a href="DROPBOXURL"><i class="ion-ios-email-outline"></i></a>
                        <a href="#"><i class="ion-ios-location-outline"></i></a>

</div></figcaption></figure>
        <!---  END INFO CARD --->

        <!---  BEGIN INFO CARD --->
<figure class="infocard infotypethree factiontypethree">

<img src="ICON" class="background"/>
<img src="ICON" class="profile"/>


<figcaption> <h3>


<a href="#">TITLE</a>


<br><span>

SUBTITLE ● 

<a href="#">MAIN LINK</a> <br>

INFO #2 | INFO #3

</span></h3><div class="icons">

                        <a href="PROFILEURL"><i class="ion-ios-person-outline"></i></a>
                        <a href="DROPBOXURL"><i class="ion-ios-email-outline"></i></a>
                        <a href="#"><i class="ion-ios-location-outline"></i></a>

</div></figcaption></figure>
        <!---  END INFO CARD --->

        <!---  BEGIN INFO CARD --->
<figure class="infocard infotypefour factiontypefour">

<img src="ICON" class="background"/>
<img src="ICON" class="profile"/>


<figcaption> <h3>


<a href="#">TITLE</a>


<br><span>

SUBTITLE ● 

<a href="#">MAIN LINK</a> <br>

INFO #2 | INFO #3

</span></h3><div class="icons">

                        <a href="PROFILEURL"><i class="ion-ios-person-outline"></i></a>
                        <a href="DROPBOXURL"><i class="ion-ios-email-outline"></i></a>
                        <a href="#"><i class="ion-ios-location-outline"></i></a>

</div></figcaption></figure>
        <!---  END INFO CARD --->

        <!---  BEGIN INFO CARD --->

<figure class="infocard infotypefive factiontypefive">

<img src="ICON" class="background"/>
<img src="ICON" class="profile"/>


<figcaption> <h3>


<a href="#">TITLE</a>


<br><span>

SUBTITLE ● 

<a href="#">MAIN LINK</a> <br>

INFO #2 | INFO #3

</span></h3><div class="icons">

                        <a href="PROFILEURL"><i class="ion-ios-person-outline"></i></a>
                        <a href="DROPBOXURL"><i class="ion-ios-email-outline"></i></a>
                        <a href="#"><i class="ion-ios-location-outline"></i></a>

</div></figcaption></figure>
        <!---  END INFO CARD --->

</main></div>
</form></div>

I am in a quandary. I'm not very knowledgeable in CSS, and this CMS (which I must use, unfortunately) makes even the easiest of tasks inordinately difficult. Here's what I've tried:

  • Using nth-child / nth-of-type selectors: I was given this idea by Temani Afif. This solution is elegant and I loved it, but unfortunately, because of what the code will be used for, the structure will vary often.

  • Placing the input above the labels: I've been advised to look into this, but I can't find any information on how to properly code with the input above the label, so I'm unsure if it can be used in this
    situation.

  • I thought about mimicking the behavior I want using [attribute|=value] selectors instead of id, but I haven't been able to get it to work. I don't know, though, whether I'm being limited by the code or my own incompetence, so I'm unsure if it's something worth looking into further.

So… Is there a recommended means of overcoming the id= limitations I've missed in my research?

FWIW, the purpose of this is to create a simple(ish) code where it's easy to append the INFO CARD part of the code as many times as needed to edit this for sorting movies/books/other information of that nature, while maintaining the ease at which one can change the figure class=.




Dynamic Checkbox Filter Bar Without Page Refresh

I would like to design a web page which plots data from an SQL database and allows the user to filter the input according to selections from check boxes, which are driven by data in the database.

Before I continue, I realise this website isn't meant for people to solve open ended problems like my statement above. I'm not looking for that. There is just one part I'm stuck with, hence my post. Keep reading and I'll explain...

Ok, I currently have a website on an intranet page which pulls data from an SQL server and plots the data using plotly.js. This works fine however it currently operates via the user submitting html forms which (a) refreshes the page and (b) isn't how I would like it to operate. I would like to have the page displayed as a series of check boxes on the left hand side, which are fed from the presence (or absence) or data found in the database. These checkboxes would sit in categories in an 'accordion' style list, much like the one featured on this page (https://www.w3schools.com/w3css/w3css_sidebar.asp).

So, I can easily write some PHP to query the database and create checkboxes according to the response of a SQL SELECT query. I can also easily write some code to loop through the check boxes to establish which are checked. The response to this would then be used to design a complex SELECT query which then feeds data to the ploty.js code. All this is relatively easy but I'm mentioning it to set the scene.

This is the part I'm stuck with. I want this page to react instantly to when a user checks a checkbox. On the selection I want the page to do two things:

  1. Disable checkboxes which are no longer valid based on the users current selections. What do i mean by this? Let's assume that the SQL database contains data on cakes, biscuits and fruit. Within each of these categories, there are several sub categories e.g. cake-sponge, cake-chocolate, cake-jam, biscuit-chocolate, biscuit-lemon, fruit-strawberry, fruit-banana, fruit-grapefruit. Initially all categories are available since the user has not selected anything. When the user checks the 'cake' checkbox, I would like the remaining check boxes (e.g. biscuit, fruit and all the non-cake related sub checkboxes e.g lemon, strawberry, banana, grapefruit) to be disabled. I want to keep them visible since the user may later change their mind on the filter but I want the user to not be able to select checkboxes which are not relevant.

  2. Refresh the SQL SELECT query which feeds the plotly.js plot and update the plot.

The first of these I can achieve by refreshing the page and looping over the checkboxes shown and disabling them accordingly. The second I can again do by refreshing the page. However, I would like to do them without refreshing the page. I'm sure this is do-able since it seems to be how most of the faceted filters appear to work e.g. www.skyscanner.net

Any advice on how I can do this without refreshing the page would be much appreciated. All I'm looking for is the name of a technique I can research or a rough idea, not a working solution.

Thanks for your help in advance




Show total checkbox count on multiple locations on the same page

Im am using the following code to count the check boxes and display the total count and its working fine. But now i want to display the total count on two different locations on the same page, but it does not work. What am i doing wrong ?

    <input type="checkbox" name="E33" />A
    <input type="checkbox" name="E34" />B
    <input type="checkbox" name="E66" />C

    <p id="result">Total Number of Items Selected = <p>
    <p id="result">Total Number of Items Selected = <p>

    *also show total count inside the text input 
    <input type="text" id="result" name="total" placeholder="show total count"/>



<script>
showChecked();
function showChecked(){
  document.getElementById("result").textContent = "Total Number of Items Selected = " + document.querySelectorAll("input:checked").length;
}
document.querySelectorAll("input[type=checkbox]").forEach(i=>{
 i.onclick = function(){
  showChecked();
 }
});
</script>




Backbone's checkbox toggle

I have a checkbox(es) and I am trying to change a bool field of a model when a click event happens.

My HTML checkbox:

<input class="toggle" type="checkbox" >

My model-view JS:

app.SampleView = Backbone.View.extend({

    tagName:  'li',

    template: _.template($('#item-template').html()),

    events: {
        'click .toggle:checkbox': 'toggleChecked'
    },

...

    toggleChecked: function (e) {
        var $target = $(e.target);
        var selected = $target .is(':checked');
        this.model.save({
            isChecked: selected
        });
    },
})

This is the current behavior: The checkbox and the value of the field in the model are false too. When I click once to the checkbox then the value of the "isChecked" field will be true which is good but it doesn't apply any change on the screen (checkbox looks unchecked). When I click to the checkbox second time, then the value of the "isChecked" is still true, and now finally the checkbox looks checked. When I click to the checkbox third time, then the value of the "isChecked" is false, and the checkbox looks unchecked which is also good.

Maybe there is a better way to connect the fields in backbone but I'm quite new with this framework. Thank you for any help!




samedi 28 juillet 2018

Checked items of checkbox of datagridview c#

I have added checkbox in datagridview and I want check whether an item is checked or not but I am little bit confuse how to accomplish it.
This is Xmal code

<DataGrid.Columns>
                    <DataGridTemplateColumn Header="#">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <CheckBox x:Name="checkboxinstance" Checked="checked_it" Unchecked="unchecked_it"/>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Binding="{Binding apiName }" Header="Name"   />
                </DataGrid.Columns>

This is behind the code

private void checked_it(object sender, RoutedEventArgs e)
    {
        List<CheckBox> checkBoxlist = new List<CheckBox>();
   foreach (CheckBox c in checkBoxlist)
   {
     //what I add here
   }
  }

If anyone know solution kindly help




Button for checkbox worked once

I have created checkboxes. When user check any item the item display in datagridview.
This is the code of checkbox in xmal

<Grid Background="#FFE5E5E5">

                                    <ListBox HorizontalAlignment="Stretch"  Name="APIList" 
                      VerticalAlignment="Stretch" ItemsSource="{Binding Tables[0]}"  
                      ItemTemplate="{StaticResource NameColumnTemplate}" 
                      ScrollViewer.VerticalScrollBarVisibility="Auto" 
                     BorderBrush="#FFAD7F30"  
             SelectionChanged="lst_SelectionChanged" CheckBox.Click="lst_SelectionChanged"/>
                                    <Button Content="listbox" Height="23" HorizontalAlignment="Left" Margin="214,207,0,0" Name="btnShowSelectedItems" 
            VerticalAlignment="Top" Width="75" Click="btnShowSelectedItems_Click" />


                            </Grid>

This is the code behind

 private void btnShowSelectedItems_Click(object sender, RoutedEventArgs e)
    {
        string path, name;
        int i = 0,c=0, result;
        string[] lines = System.IO.File.ReadAllLines(@"D:\7th semester\FYP\source\repos\dllPaths.txt");
        string[] selecteditem = new string[50];
        var showapi = APIList.ItemsSource as List<showAPI>;
        var apinames = new List<showAPI>();
        foreach (var item in showapi)
        {
            if (item.IsSelected == true)
            {
                selecteditem[i] = item.apiName;
            }
        }
        foreach (string line in lines)
        {
            foreach (string select in selecteditem)
            {
                if (select == line)
                {
                    name = select + ".exe";
                    path = lines[i + 1];
                    result = injection(name, path);
                    if (result == 1)
                    {
                        apinames.Add(new showAPI
                        {
                            ID = 1,
                            apiName = select,
                            dateTime = DateTime.Now.ToString()
                        });
                    }
                    else { Textbox1.Text = c.ToString(); }
                }
            }
        }


        dg1.ItemsSource = apinames;
    }
    private void lst_SelectionChanged(object sender, RoutedEventArgs e)
    {
        var listBox = sender as ListBox;
        if (listBox.SelectedIndex > -1)
        {

            Console.WriteLine(APIList.SelectedIndex);
            Console.WriteLine(((CheckBox)APIList.SelectedItem).IsChecked);
        }
    }

When user click on button checked items display in table but if user again check more items and again click on button nothing happen and result remain unchanged. In short this button work only once.
If anyone know solution kindly help




How to populate list of checkbox values with AngularJS?

I am trying to build a quiz application in angular js with serverside for that i have 2 type of choices:

  1. Multiple options for one question (input-checkbox). "dataType": 3,
  2. Single option for one question. (input-radio) "dataType": 2,

I am trying to populate stored answer for multiple checkbox questions in this case storedAnswer is an array, whereas storedAnswer is an integer value for input radio

Note: storedAnswer array contains the option.questionChoiceValue's

My question is how can i populate array value as checked for multiple choice (checkbox) question:

This is my HTML code:

<div ng-repeat="question in data.questionData">

    <span name="multiSelectCheckBox" ng-if="question.dataType == 3">
        <div ng-repeat="option in question.choices " class="">
            <label for="mul__ques">
                <span ng-repeat="stAns in question.storedAnswer" ng-if="stAns == option.questionChoiceValue">
                    <input id="mul__ques" type="checkbox" ng-model="question.storedAnswer"   ng-change="onSelect(question, option);" />  
                </span>
            </label>
        </div>
    </span>

    <span name="multiSelectCheckBox" ng-if="question.dataType == 3">
        <div ng-repeat="option in question.choices  " class="">
            <label for="sin__ques">

                <input type="radio" id="sin__ques" 
                ng-model="question.storedAnswer" value=""  name="que_ques"  ng-change="onSelect(question, option);" />  

            </label>
        </div>
    </span>
</div>

I have an object like this:

[
    {
        "marked": "false",
        "questionId": "7d00a35ddb6313004f3bdde748961969",
        "helpText": "",
        "answered": "true",
        "storedAnswer": [
            1,
            5
        ],
        "questionSno": 1,
        "dataType": 3,
        "choices": [
            {
                "questionId": "7d00a35ddb6313004f3bdde748961969",
                "questionChoiceValue": 5,
                "questionChoiceText": "Float, long double"
            },
            {
                "questionId": "7d00a35ddb6313004f3bdde748961969",
                "questionChoiceValue": 4,
                "questionChoiceText": "Float"
            },
            {
                "questionId": "7d00a35ddb6313004f3bdde748961969",
                "questionChoiceValue": 3,
                "questionChoiceText": "float, double, long double"
            },
            {
                "questionId": "7d00a35ddb6313004f3bdde748961969",
                "questionChoiceValue": 2,
                "questionChoiceText": "long double, short int"
            },
            {
                "questionId": "7d00a35ddb6313004f3bdde748961969",
                "questionChoiceValue": 1,
                "questionChoiceText": "short int, double, long int, float"
            }
        ],
        "questionText": "In C, what are the various types of real data type (floating point data type)?",
        "selected": "false"
    },
    {
        "marked": "false",
        "questionId": "93e5c5e5db6713004f3bdde748961957",
        "helpText": "",
        "answered": "false",
        "storedAnswer": 1,
        "questionSno": 3,
        "dataType": 2,
        "choices": [
            {
                "questionId": "93e5c5e5db6713004f3bdde748961957",
                "questionChoiceValue": 3,
                "questionChoiceText": "May be"
            },
            {
                "questionId": "93e5c5e5db6713004f3bdde748961957",
                "questionChoiceValue": 2,
                "questionChoiceText": "False"
            },
            {
                "questionId": "93e5c5e5db6713004f3bdde748961957",
                "questionChoiceValue": 1,
                "questionChoiceText": "True"
            }
        ],
        "questionText": "A macro can execute faster than a function.",
        "selected": "false"
    }
]

enter image description here




Show sum of values for all checkboxes that are checked

I’m creating an HTML form and want to achieve the following with JS, please provide the code i should use to do so.

1.Add values of all the checked checkboxes and show them as total.

2.Add a restriction the user must select at least 2 checkboxes. Here is my code.

<input class="iput" type="checkbox" name="E33" value="4500" />
<input class="iput" type="checkbox" name="E34" value="3000" />
<input class="iput" type="checkbox" name="E36" value="6000" />

<p>Your Total is = </p>

Also code should be such that if i add or remove checkboxes i should not have to modify the JS code too.




vendredi 27 juillet 2018

Restrict checkboxes checked. Javafx

How to restrict the number of checkboxes that a user can select? I want to make it so the user can only select 3. I think I should use isSelected, but I don't know how to link all the checkboxes.

    CheckBox cb1 = new CheckBox("Pepperoni");
    CheckBox cb2 = new CheckBox("Cheese");
    CheckBox cb3 = new CheckBox("Tomato");
    CheckBox cb4 = new CheckBox("Olives");
    CheckBox cb5 = new CheckBox("Chicken");
    //if 3 are already selected, it should not be possible for the user to select more




How to limit selection of checkboxes, based on selected radiobutton (JAVA FX)

Is it possible to limit the number of checkboxes that can be selected, based on a radiobox that the user selects in the same scne? In my code, there are 2 radiobuttons and 5 color checkboxes. You can only select one radiobutton. If "dog" is selected, I only want the user to be able to select 2 colors. If "cat" is selected, I only want the user to be able to select 3 colors.

    GridPane lay1 = new GridPane();
    lay1.setHgap(0);
    lay1.setVgap(20);

    RadioButton dog = new RadioButton("dog");
    RadioButton cat = new RadioButton("cat");
    ToggleGroup type = new ToggleGroup();
    dog.setToggleGroup(type);
    cat.setToggleGroup(type);
    VBox types = new VBox(20);
    types.getChildren().addAll(dog,cat);
    lay1.add(types, 0, 3);

    CheckBox cb1 = new CheckBox("red");
    CheckBox cb2 = new CheckBox("yellow");
    CheckBox cb3 = new CheckBox("black");
    CheckBox cb4 = new CheckBox("white");
    CheckBox cb5 = new CheckBox("green");

    VBox colors = new VBox(15);
    colors.getChildren().addAll(cb1, cb2, cb3, cb4, cb5);
    lay1.add(colors, 0, 4);`




Ionic Listview with checkboxes

Hi i am new for Ionic and in my listview each row having checkbox and my application user have a option to select multiple items using checkbox,How ca i implment this functionality can some one help me please.

.html:

<ion-content padding>
  <ion-list>
    <ion-item *ngFor="let contact of contacts">
        <ion-label> </ion-label>
        <ion-checkbox (ionChange)="updateCheckbox()"></ion-checkbox>
    </ion-item>
</ion-list>
</ion-content>

.ts:-

export class CheckboxListPage {

  contacts:any

  constructor(public navCtrl: NavController, public navParams: NavParams) {

    this.contacts = [{"id":1,"name":"ram1"},
    {"id":1,"name":"ram2"},
    {"id":1,"name":"ram3"},
    {"id":1,"name":"ram4"];
  }
}




Radio Button not performing JavaScript action when clicked

I am trying to create a radio button that opens up an additional checkbox. When I run the code, the checkbox is already open. what can I do to fix it?

<script>
  function accountFunction() {
    if (document.getElementById('yesSrm').checked) {
      document.getElementById('acct').style.display = "inline";
    } else {
      document.getElementById('acct').style.display = "none";
    }
</script>
<form>
  <input id="yesSrm" name="yesSrm" type="radio" value="yes" onchange="accountFunction()" />SRM<br/>
  <br/>
  <div id="acct">
    <label for="account">Account</label>
    <input type="checkbox" name="account" id="account"><br/>
  </div>
</form>

How it appears




Count total number of checkboxes what are checked and show on page via JS

I want to show the total number of checkboxes that user has selected on the page. Here is my code.

<input type="checkbox" name="fruit" />A
<input type="checkbox" name="fruit" />B
<input type="checkbox" name="fruit" />C

<p>Total Number of Items Selected = <p>  

Please provide the javascript code needed to achieve this.




Rails Checkbox format

I am trying to output checkbox with hard coded checkbox value, so far I have coded

<%= form.collection_check_boxes(:study_type,['Option1','Option2'], :first, :first)%>

The output for checkbox label is first alphabet of respective checkbox. Any way to display full text value label.

Thanks for help.




unable to get checkbox values

I have the following code. I want to get only selected checkbox values but I get only last checkbox value. see what's wrong in my code.

<div class="box-body table-responsive no-padding">
                            <h4>Select Jobwork</h4>

                               <table id="data-table" class="table table-hover jobworks-table table-responsive">
                                    <thead>
                                        <tr style="background-color: #DDDD; color:firebrick;">
                                            <th><input type='checkbox' value="1" name="select_all" /></th>
                                            <th>JobWork Name</th>
                                            <th>Description</th>
                                            <th>Price</th>
                                        </tr>
                                    </thead>
                                   <tbody>
                                <?php foreach ($item as $key=>$value){
                                $decoded = json_decode($value['jobWorkJsonString']); ?>
                                       <?php foreach($decoded as $row){ ?>
                                            <tr class="odd gradeX">
                                                <td><input type='checkbox' name="<?php echo $row->jobwork; ?>" /></td>
                                                <td style="padding-left:0px;"><?php echo $row->jobwork; ?><input type="hidden" name="jobwork_name" value="<?php echo $row->jobwork; ?>"></td>
                                                <td style="padding-left:0px;"><?php echo $row->description; ?><input type="hidden" name="jobwork_description" value="<?php echo $row->description; ?>"></td>
                                                <td style="padding-left:0px;"><?php echo $row->jobPrice; ?><input type="hidden" name="price" value="<?php echo $row->jobPrice; ?>"></td>        
                                                <?php } ?>
                                            </tr>
                                    <?php } ?>
                                    </tbody>
                                </table>
                            <br>
                        </div>




jeudi 26 juillet 2018

can we hide and show child checkbox when click on specific parent checkbox

I want to display specific child checkbox when click on parent checkbox but the value of checkbox is come from database column

 <input name="service[]" type="checkbox" value="<?php echo $service['id']; ?>" id="" />

<?php 
echo $service['servicename'];
echo "<br>";
?>

<br><br>

<?php foreach ($activities as $activity) : ?>

    <input name="activity[]" type="checkbox" value="<?php echo $activity['id']; ?>" />

    <?php 
    echo $activity['nameofactivity'];
    echo "<br>"; 

My Output:

  • 1.Incometax
  • Return
  • Filling
  • 2.GST
  • Form
  • submitform

I want to display Return and Flling [activity of 1 st service] when click on Incometax[1 st service]and display Form and submitform[activity of 2 nd service] when click on [2nd service ]GST. but when click on incometax[1 st service] then hide Form and submitform[activity of second if opens] and when i click on GST[2 nd service] then hide Return and Filling [activity of 1 st service if opens]

Thanks.




How to make a checkbox unchecked based on another checkbox selection?

I have 6 checkboxes in my application.

   <input type="checkbox" name="vehicle" id="vehicle1" value="one">one<br>
   <input type="checkbox" name="vehicle" id="vehicle2" value="two">two<br>
   <input type="checkbox" name="vehicle" id="vehicle3 value="three">three<br>
   <input type="checkbox" name="vehicle" id="vehicle4" value="four">four<br>
   <input type="checkbox" name="vehicle" id="vehicle5" value="five">five<br>
   <input type="checkbox" name="vehicle" id="all" value="all">all<br>

And I have this jquery function, which would disable every other checkbox if the "all" checkbox is clicked.

    $("#all").change(function(){
       var $inputs = $('input:checkbox')
        if($(this).is(':checked')){
           $inputs.not(this).prop('disabled',true);
        }
       else{
           $inputs.prop('disabled',false);
        }
   });

If I select a checkbox other than the "all" checkbox, I have this following code which would disable the "all" checkbox.

  $("[type=checkbox]").click(function() {
    if((this.value == "one") || (this.value == "two") || (this.value == "three") || (this.value == "four") || (this.value == "five")){
     $( "#all" ).prop( 'disabled', true );
    }
    else{
      $( "#all" ).prop( 'disabled', false );
    }
  });

My problem here is, if I try to uncheck a checkbox after selecting it, this "all" checkbox is still disabled. I want it to be enabled once any checkbox is unchecked. Can you guys please help me with this?




WPF switching column visibility in DataGrid triggers unwanted event

I have a weird issue where changing data grid column visibility with a press of a button, it triggers a "Checked" event tied to a checkbox in that data grid column.

So here's my setup:

  • I have a label (lblUpdateMode) with a text either "single row" or "every row";

  • A datagrid with 10 columns, where initially 5 columns are visible and 5 are hidden;

  • Pressing a button (btnChangeView) flips visibility of each column;

  • In one of the data grid columns I have a CheckBoxColumn, with Checked/Unchecked events. If label text = "every row" pressing on a single checkbox updates every row.

However, if label = "every row" and I press on btnChangeView, it also triggers Checked event and updates checkboxes in every row.

Why is this happening and how can I avoid it?

Here's the code to the Checked event - nothing fancy or strange:

private void UpdateDataGridCheckBox(string colname, bool v)
        {
            if (lblUpdateMode.Content.ToString() == "Every Row")
            {
                foreach (DataRow dr in DataAccess.Instance.sourceFiles.Rows)
                {
                    dr[colname] = v;
                }
            }
        }

Thanks




Vanilla JS: Loop through checkboxes and conditionally disable unchecked

I'm trying to write a basic function in pure JS that simply checks the number of checked checkboxes, and if that number exceeds a certain amount, disables the rest. I can achieve this easily in jQuery, but trying to get it working in pure JS. I have a CodePen set up here and I'm including my working JS below. Thanks for any insight here.

(function() {

  var checkboxes = document.querySelectorAll('input[id^="mktoCheckbox"]');
  var active = document.querySelectorAll('input[id^="mktoCheckbox"]:checked');
  var numActive = active.length;

  console.log(numActive);

  if (numActive > 1) {
    for(var i = 0; i < checkboxes.length; i++){
            if (checkboxes[i].checked == true) {
                return;
            } else {
                checkboxes[i].disabled == true;
            }
        }
  }

})();




Issue with extjs checkbox header

I'm currently implementing part of a project in ExtJS, the requires me to modify an existing grid to only show checkboxes on rows with a certain status(different than AN, NP, RS), this status is determined by the value in record.data.codiceStato :

 selectionModel = Ext.create('Ext.selection.CheckboxModel', 
               {checkOnly : true, 
            listeners : {
                select:function(sm, idx, rec ){
                    alert("Look ma!");
                }, 
                beforeSelect : function(sm, idx, rec ) {

                     if(idx.data.codiceStato == 'RS' || idx.data.codiceStato == 'AN' || idx.data.codiceStato == 'NP')
                         return false; 

                }

             }      
                ,renderer : function(value, metaData, record, rowIndex, colIndex, store, view) {
                    if(record.data.codiceStato != 'RS' && record.data.codiceStato != 'AN' && record.data.codiceStato != 'NP')
                        return '<div style="margin-left: -1px;" class="' + Ext.baseCSSPrefix + 'grid-row-checker"> </div>'; 

                    else 
                        return ''; 
                }
           });

I have written a check in my beforeSelect listener in order to avoid the checkbox selecting the rows that do not have this status and it works. The only problem is with the header checkbox now, in fact, when I click on it the first time it enables all the rows with a checkbox, but then it doesn't uncheck them when I click on it again. Any solutions ? Thank you




Checked="checked" not working in angularjs while checking a checkbox using conditions

I need to check a checkbox based on conditions. In my case, the function returns true for ng-checked.But after submit,the value shown as not checked. Any solutions for this?, greatly appreciated. Here I have tried so far:

$scope.findViewTocheck = function (module) {
        if (module.x|| module.y|| module.z|| module.a) {
            return true; // module.x ,module.y ,module.z,module.a these are booleans
        }
        else {
            return false;
        }
    }

<input type="checkbox" ng-checked="findViewTocheck(module)"> //Here I am checking the value to be checked or not.




How to get the value of checked radioButton so that i am able to display them in next Activity in checkbox form?

I am building a quiz app in which user selects one of the radioButton from each one cards(each card contains one question with four options) and on pressing the submit floatingActionButton the user can see which has he/she solved on the next Activity .A checkbox below a question number means that he has solved that question. I have searched everywhere but cant get anything helpful.I am stuck in my project.Here are my Codes MainActivity.java

package com.pratyush.onlineexamapp;
public class MainActivity extends AppCompatActivity {
private ArrayList<ModelClass> questionList = new ArrayList<>();
private RecyclerView recyclerView;
FloatingActionButton fabactsbmt,fabctprv;
private QuestionAdapter qAdapter;
private static final String FORMAT = "%02d:%02d";
private RadioGroup rg;
private RadioButton rb;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    recyclerView = (RecyclerView) findViewById(R.id.rcyclvw);
    final TextView timer=(TextView)findViewById(R.id.timer) ;
    int selectedId=rg.getCheckedRadioButtonId();
    rb=(RadioButton)findViewById(selectedId);
    qAdapter= new QuestionAdapter(this);
    fabactsbmt=(FloatingActionButton)findViewById(R.id.sbmtBtn);
    fabctprv=(FloatingActionButton)findViewById(R.id.prevwBtn);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getApplicationContext(),LinearLayoutManager.HORIZONTAL, false);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(qAdapter);


    fabctprv.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Intent it= new Intent(MainActivity.this,PreviewDetails.class);
            String selectedFromList = (recyclerView.getItemAtPosition(position));
            it.putIntegerArrayListExtra("Respone",);
            rg.clearCheck();
            startActivity(it);
        }
    });
    fabactsbmt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(MainActivity.this,"Your test will be submitted without taking you to Preview Activity",Toast.LENGTH_SHORT).show();
        }
    });

    new CountDownTimer(60000, 1000) { // adjust the milli seconds here

        public void onTick(long millisUntilFinished) {

            timer.setText("Time Left:" + " " + String.format(FORMAT,
                    TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(
                            TimeUnit.MILLISECONDS.toHours(millisUntilFinished)),
                    TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(
                            TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished))) + "/01:00");
        }

        public void onFinish() {

            AlertDialog.Builder builder = new AlertDialog.Builder(
                    MainActivity.this);
            builder.setTitle("Time Out!!!");
            builder.setMessage("Your Score is" + " " + 100);
            builder.setCancelable(false);
           /* builder.setNegativeButton("NO",
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog,
                                            int which) {
                            Toast.makeText(getApplicationContext(),"No is clicked",Toast.LENGTH_LONG).show();
                        }
                    });*/
            builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    System.exit(0);
                }
            });
            builder.show();
        }
    }.start();

    prepareTest();
}
public void prepareTest(){

    ModelClass que1=new ModelClass();
    que1.setQueNo("Question:- 1/11");
    que1.setQue("who is the prime minister of india?");
    que1.setOptn1(" Manmohan Singh");
    que1.setOptn2(" Sonia Gandhi");
    que1.setOptn3(" Narendra Modi");
    que1.setOptn4(" Amit Shah");
    que1.setAnswer("Narendra Modi");
    questionList.add(que1);

    ModelClass que2=new ModelClass();
    que2.setQueNo("Question:- 2/11");
    que2.setQue("who is the firs prime minister of india?");
    que2.setOptn1("a) Manmohan Singh");
    que2.setOptn2("b) Sonia Gandhi");
    que2.setOptn3("c) Narendra Modi");
    que2.setOptn4("d) Rajeev Gandhi");
    questionList.add(que2);

    ModelClass que3=new ModelClass();
    que3.setQueNo("Question:- 3/11");
    que3.setQue("who is the president of india?");
    que3.setOptn1("a) Manmohan Singh");
    que3.setOptn2("b) Sonia Gandhi ");
    que3.setOptn3("c) Narendra Modi");
    que3.setOptn4("d) Pratibha Patil");
    questionList.add(que3);

    ModelClass que4=new ModelClass();
    que4.setQueNo("Question:- 4/11");
    que4.setQue("Nobel prize is awarded for which of the following disciplines:");
    que4.setOptn1("a) Literacy,physics");
    que4.setOptn2("b) Chemistry");
    que4.setOptn3("c) Medicine or Physiology");
    que4.setOptn4("d) All of the Above");
    questionList.add(que4);

    ModelClass que5=new ModelClass();
    que5.setQueNo("Question:- 5/11");
    que5.setQue("Garampani Sanctuary is locate in which of the following places:");
    que5.setOptn1("a) Junagarh, Gujarat");
    que5.setOptn2("b)  Kohima, Nagaland");
    que5.setOptn3("c) Diphu, Assam");
    que5.setOptn4("d) Gangtok, Sikkim");
    questionList.add(que5);

    ModelClass que6=new ModelClass();
    que6.setQueNo("Question:- 6/11");
    que6.setQue(" Entomology studies what?");
    que6.setOptn1("a) Behavior of human beings");
    que6.setOptn2("b) Insects");
    que6.setOptn3("c) The origin and history of technical and scientific terms");
    que6.setOptn4("d) The formation of rocks");
    questionList.add(que6);

    ModelClass que7=new ModelClass();
    que7.setQueNo("Question:- 7/11");
    que7.setQue("Galileo was an astronomer who");
    que7.setOptn1("a) developed the telescope");
    que7.setOptn2("b) discovered four satellites of Jupiter");
    que7.setOptn3("c) discovered that the movement of pendulum produces a regular time measurement");
    que7.setOptn4("d) All the above");
    questionList.add(que7);

    ModelClass que8=new ModelClass();
    que8.setQueNo("Question:- 8/11");
    que8.setQue("Who is the father of geometry?");
    que8.setOptn1("a) Aristotle");
    que8.setOptn2("b) Pythagoras");
    que8.setOptn3("c) Euclid");
    que8.setOptn4("d) Kepler");
    questionList.add(que8);

    ModelClass que9=new ModelClass();
    que9.setQueNo("Question:- 9/11");
    que9.setQue("Indian Player Jude Felix is associated with");
    que9.setOptn1("a) Volleyball");
    que9.setOptn2("b) Football");
    que9.setOptn3("c) Hockey");
    que9.setOptn4("d) Tennis");
    questionList.add(que9);

    ModelClass que10=new ModelClass();
    que10.setQueNo("Question:- 10/11");
    que10.setQue("The Indian, who holds the pride of beating the computers in mathematical wizard is:");
    que10.setOptn1("a) Shakuntala Devi");
    que10.setOptn2("b) Raja Ramanna");
    que10.setOptn3("c) Ramanujam");
    que10.setOptn4("d) Rina Panigrahi");
    questionList.add(que10);

    ModelClass que11=new ModelClass();
    que11.setQueNo("Question:- 11/11");
    que11.setQue("Who is popularly called as the Iron Man of India?");
    que11.setOptn1("a) Subhash Chandra Bose");
    que11.setOptn2("b) Sardar Vallabhbhai Patel");
    que11.setOptn3("c) Govind Ballabh Pant");
    que11.setOptn4("d) Jawaharlal Nehru");
    questionList.add(que11);

}
public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.MyViewHolder> {


    Context context;
    public QuestionAdapter(Context context) {
        this.context = context;

    }

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

        return new MyViewHolder(itemView);
    }

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

        ModelClass model = questionList.get(position);

        holder.queNo.setText(model.getQueNo());
        holder.que.setText(model.getQue());
        holder.opt1.setText(model.getOptn1());
        holder.opt2.setText(model.getOptn2());
        holder.opt3.setText(model.getOptn3());
        holder.opt4.setText(model.getOptn4());
       // Picasso.with(context).load(model.getImg()).into(holder.imgvw);




    }

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


    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        private TextView queNo,que,opt1,opt2,opt3,opt4;


        public MyViewHolder(View view) {
            super(view);
            //RadioGroup radioGroup=(RadioGroup)findViewById(R.id.rgrp);
            //RadioButton checkedButton = (RadioButton)findViewById(radioGroup.getCheckedRadioButtonId());
            queNo = (TextView) view.findViewById(R.id.qNotext);
            que = (TextView) view.findViewById(R.id.queText);
            opt1 = (RadioButton) view.findViewById(R.id.opt1);
            opt2 = (RadioButton) view.findViewById(R.id.opt2);
            opt3 = (RadioButton) view.findViewById(R.id.opt3);
            opt4 = (RadioButton) view.findViewById(R.id.opt4);
        }
    }
}

Here is my Preview Activity.java

package com.pratyush.onlineexamapp;
public class PreviewDetails extends AppCompatActivity {
private ArrayList<Model> modelArrayList= new ArrayList<>();
GridView gridView;
FloatingActionButton finalSubmit;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_preview_details);
    gridView=(GridView)findViewById(R.id.gridView);
    finalSubmit=(FloatingActionButton)findViewById(R.id.finalsbmt);
    prepareData();

    ResponseAdapter adapter=new ResponseAdapter(this);
    gridView.setAdapter(adapter);

    finalSubmit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(PreviewDetails.this,"Your Test will be submitted",Toast.LENGTH_SHORT).show();
        }
    });



}
public void prepareData(){
    Model qno1=new Model();
    qno1.setQnumber("Question no.1");
    qno1.setCb(true);
    modelArrayList.add(qno1);

    Model qno2=new Model();
    qno2.setQnumber("Question no.2");
    qno2.setCb(true);
    modelArrayList.add(qno2);

    Model qno3=new Model();
    qno3.setQnumber("Question no.3");
    qno3.setCb(false);
    modelArrayList.add(qno3);

    Model qno4=new Model();
    qno4.setQnumber("Question no.4");
    qno4.setCb(true);
    modelArrayList.add(qno4);

    Model qno5=new Model();
    qno5.setQnumber("Question no.5");
    qno5.setCb(false);
    modelArrayList.add(qno5);

    Model qno6=new Model();
    qno6.setQnumber("Question no.6");
    qno6.setCb(true);
    modelArrayList.add(qno6);

    Model qno7=new Model();
    qno7.setQnumber("Question no.7");
    qno7.setCb(true);
    modelArrayList.add(qno7);

    Model qno8=new Model();
    qno8.setQnumber("Question no.8");
    qno8.setCb(true);
    modelArrayList.add(qno8);

    Model qno9=new Model();
    qno9.setQnumber("Question no.9");
    qno9.setCb(false);
    modelArrayList.add(qno9);

    Model qno10=new Model();
    qno10.setQnumber("Question no.10");
    qno10.setCb(true);
    modelArrayList.add(qno10);

    Model qno11=new Model();
    qno11.setQnumber("Question no.11");
    qno11.setCb(true);
    modelArrayList.add(qno11);
}
private class ResponseAdapter extends BaseAdapter{

    private Context context;
    private LayoutInflater layoutInflater;

    private ResponseAdapter( Context context){
        this.context=context;

    }

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

    @Override
    public Object getItem(int i) {
        return modelArrayList.get(i);
    }

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

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (layoutInflater==null)
            layoutInflater=(LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
        if (view==null)
            view=layoutInflater.inflate(R.layout.custom_grid,null);
        TextView tv=(TextView) view.findViewById(R.id.tetView);
        CheckBox checkBox=(CheckBox) view.findViewById(R.id.checkboxe);

        tv.setText(modelArrayList.get(i).getQnumber());
        checkBox.setChecked(modelArrayList.get(i).getCb());

        return view;
    }
}

**For now i have just set those values in checkboxes manually.Thanks in advance **




Checking rows in extjs grid based on their state

I'm currently working on a project that uses ExtJS.

For this part of the project I had to implement a checkbox column on an existing grid, each row of the grid can have a state determined by record.data.codiceStato.

Here is part of the code :

 selectionModel = Ext.create('Ext.selection.CheckboxModel', 
               {  checkOnly : true, 
            listeners:{
                select:function(sm, idx, rec ){alert("Look ma!")}

             }      
                ,renderer : function(value, metaData, record, rowIndex, colIndex, store, view) {
                    if(record.data.codiceStato == 'RS' || record.data.codiceStato == 'AN' || record.data.codiceStato == 'NP')
                        return '<div style="margin-left: -1px;" class="' + Ext.baseCSSPrefix + 'grid-row-checker"> </div>'; 
                    else 
                        return ''; 
                }
           });

Now, as you can see, I only render the checkbox on certain rows that have a precise state(RS, AN, NP). My problem is that when I click on the header checkbox ALL the rows in the grid get selected, also those ones that are not in the state that should be able to be selected(state different than NP RS AN). Is there any way to fix this? Thank you in advance.




Check a checkbox in partial view from Main view

A lot of questions on checkboxes, but none helped in this matter. I want to check my checkboxes in my PartialView FROM my MainView.

Please look at my Ajax function on my MainView

$.ajax({
                url: '@Url.Action("Show", "Moderator")',
                data: { search: v, productName: p }

            }).done(function(data) {
                CloseWaitDialogue();
                $('#gridContent').html(data);
                $res = $(data).filter('#qFilterGrid'); //Finding this ID in my Partial View

                if ($res) {

                    $("#qFilterGrid th").each(function() {

                        if ($.trim($(this).text().toString().toLowerCase()) === "{checkall}") {
                            $(this).text('');
                            $("<input/>",
                                {
                                    type: "checkbox",
                                    id: "cbSelectAll1",
                                    value: "",
                                    class: "selectall",
                                    onclick: "SelectCheckBox(this);"
                                }).appendTo($(this));
                            $(this).append("<span>EnableALL</span>");
                        }

                    });
                }

            }).fail(function() {
                alert("FAIL");
            });

This is my partial view:

grid.Columns(
                grid.Column("Sl.No", format: @<text>
                                                 <div>
                                                     <span class="sl-holder">@( item.WebGrid.Rows.IndexOf(item) + 1)</span> <input type="hidden" value="@item.Id" class="p-id"/>
                                                 </div> </text>, canSort: false),
                grid.Column(
                    format: @<text>
                                @if (@item.EnableQueue)
                                {
                                    <text> <input id=@( item.WebGrid.Rows.IndexOf(item) + 1) type="checkbox" value="@item.EnableQueue" checked disabled="disabled" name="ids" class="disabled-true"/></text>
                                }
                                else
                                {
                                    <text><input id=@( item.WebGrid.Rows.IndexOf(item) + 1) type="checkbox" value="@item.EnableQueue" name="ids" class="dis"/></text>
                                }
                             </text>,
                    header: "{checkall}", style: "width"
                    ),
                grid.Column("Project", format: @<text> <span class="display-mode">@item.Project </span> </text>),
                grid.Column("Version", format: @<text> <span class="display-mode">@item.Version</span></text>),
                grid.Column("Mode", format: @<text><span class="display-mode lblMode">@item.Mode</span><label class="edit-mode lblMode"></label></text>, canSort: false),
                grid.Column("Priority", "Priority", format: @<text>
                                                                <span class="display-mode">
                                                                    <label class="lblPriority">@item.Priority</label>
                                                                </span> </text>, canSort: false))

As you can see, I want the check boxes in my partial view to be checked from my main view.

Some of my attempts that didn't work.

Attempt 1

$("#cbSelectAll1").on("click", function () {

        debugger;
        var ischecked = this.checked;
        $('#qFilterGrid tr').each(function () {

            if ($(this)[0].style.cssText === "display: table-row;" || $(this)[0].style.cssText == "") {
                $(this).find("input:checkbox").each(function () {
                    if (this.disabled != true) {
                        this.checked = ischecked;
                    }


                });
            }

        });


    });

Attempt 2

function SelectCheckBox(obj) {

        var c = new Array();
        c = document.getElementsByTagName('input');
        for (var i = 0; i < c.length; i++) {
            if (c[i].type == 'checkbox') {
                c[i].checked = obj.checked;
            }
        }
    }

I tried a couple of more but none helped.

What should I write in SelectCheckBox(); function? Thank you.




mercredi 25 juillet 2018

Link Named Range to CheckBoxes in UserForm

How would I link a Named Range to a list of checkboxes populated in a userform. The amount of checkboxes varies by how much data is present. Ex. if 35 columns are added, 35 checkboxes will appear. The goal is to eventually delete the specific named range for each column (checkbox) that is checked on the userform and then hitting the delete command button. Please let me know if this is possible.




Using chekboxes on a recyclerview with firebase [duplicate]

This question already has an answer here:

How can you create a proper recycler view with CheckBox using firebase, currently I can create 5 viewHolders and everythings goes fine, when I create 6 or more viewHolder the checkboxes start checking at random. Has anyone done something similar to this? Any help would be highly appreciated!!

Currently this is my OnBindViewHolder:

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

       final Habitos habitos = mHabitosList.get(position);

 holder.nombre.setText(habitos.getNombre());

            FirebaseDatabase mDatabase = FirebaseDatabase.getInstance();
            mDatabaseReference = mDatabase.getReference("Habitos");
            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
            if(user != null) {
                userId = user.getUid();
                habitosReference = mDatabaseReference.child(userId);
                Focus focus = new Focus();
                mDays = focus.getPrevFiveDaysNumbers();
                habitosId = mHabitosList.get(position).getHabitosId();

                habitosReference.child(habitosId).child("checks").addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                            mChecks = (HashMap<String, Boolean>) dataSnapshot.getValue();
                            Log.d("Checky", mChecks+"");
                            assert mChecks != null;
                           checkBox1 = mChecks.get(mDays[0]);
                            checkBox2 = mChecks.get(mDays[1]);
                            checkBox3 = mChecks.get(mDays[2]);
                            checkBox4 = mChecks.get(mDays[3]);
                            checkBox5 = mChecks.get(mDays[4]);
                            checkListeners(holder, habitos);
                        }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                });
    }

And to listen to the checkboxes I have the following method:

private void checkListeners(MyViewHolder holder, final Habitos habitos) {
        holder.CB1.setChecked(checkBox1);
        holder.CB1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {

                String HabitosId = habitos.getHabitosId();
                int total = habitos.getTotal();
                if (b) {
                    habitosReference.child(HabitosId).child("checks").child(mDays[0]).setValue(true);
                    total++;
                } else {
                    habitosReference.child(HabitosId).child("checks").child(mDays[0]).setValue(false);
                    total--;
                }
                habitosReference.child(HabitosId).child("total").setValue(total);
            }
        });

This adds a +1 value everytime a checkbox is checked. Everything is working fine except when I add more than 5 viewHolders. Any idea how could I fix this?




sending Angular 6 form including checkbox values not working with template driven forms

I'm trying to pass form values including checkboxes in angular 6 forms using formbuilder but I'm unable to read the value from checkbox. I am getting all the values from all the other input fields but only checkbox is not responding Here is my code:

<form [formGroup]="myGroup" (submit)="submit(myGroup.value)">
    <div class="row">
      <div class="col-sm-4" *ngFor="let info of myGroup.controls['myInfo'].controls; let i = index">

            <label for=""> 
            <input type="" class="" [formControl]="info">
          </label>

      </div>
    </div>

<div class="row">
  <button class="form-control btn-sub" type=”submit”>
    Submit Details
  </button>
</div>

My component class:

import { ProposalService, CustomerDetails, ProposalNumber } from 'src/app/Services/Proposal-service/proposal.service';

export interface InputType{
  name:string;
  type: string;
  label: string;

  class:string;
}
export class ProposalComponent implements OnInit {

  public labelValue: InputType[] = [
  {name:"fname",type:"text",label:"First Name", class:"form-control"},
  {name:"form60",type:"checkbox",label:"Is Collection Of form 60", class:"form-control"},
  {name:"eia-num",type:"number",label:"EIA Number", class:"form-control"}
];
  title = "Customer Details";
  details: Observable<CustomerDetails>;
  pNumber: ProposalNumber ;

  public information: CustomerDetails[] = [
    {name:"First Name", value:""},//
 {name:"IsCollectionOfform60", value:true},
    {name:"EIA Number", value:""}
  ];

  myGroup : FormGroup;

  constructor(private formBuilder: FormBuilder,
   private _proposalService: ProposalService) { }

  ngOnInit() {

  this.myGroup = this.formBuilder.group({
    myInfo: this.constructFormArray()
  });

  this.pNumber = <ProposalNumber>{proposalNumber: 0 ,message:"", status: ""};

  } 


  constructFormArray()
  {
    const arr = this.information.map(cat => {
      return this.formBuilder.control(cat.value);
    });
    return this.formBuilder.array(arr);

  }


  submit(form){
    //this.loading = true;
    console.log(form);
    let mySelectedAddon = form.myInfo.map((currentValue,i)=> {
      return { "name" : this.information[i].name , "value" : currentValue} 
      }
    );
    console.log(mySelectedAddon);
    this._proposalService.loadCustomer(mySelectedAddon).subscribe((res: ProposalNumber) =>{
      //this.loading = false;
        console.log(res);
        this.pNumber.proposalNumber = res.proposalNumber;
        this.pNumber.message = res.message;
        console.log(this.pNumber.proposalNumber);
        return this.myGroup.value;
  });
}
}




jQuery Ajax can't change checkbox state

I am trying to change a checkbox state but it does not seems to work. This is my code:

HTML:

<div class="input_container">
    <label>Active</label>
    <input type="checkbox" name="active"/>
</div>

jQuery/Ajax:

$.ajax({
    url: 'includes/exproty.php',
    type: 'post',
    data: { 'product_id' : '100'},
    success: function(data) {
        var product_details = JSON.parse(data);
        if (product_details.is_published) {
            console.log("Works");
            $("[name='active']").checked = true;
        } else {
            $("[name='active']").checked = false;
        }
    }
});

The console.log inside the if is used in order for me to confirm the condition is met and the code inside the if is executed.

I also tried this:

$("[name='active']").prop('checked', true);

But it does not work either.

I know for certain the condition is met and is executing (thanks to the console.log).

If needed any more information, ask for it and I will try to provide it. Thanks!




Undefined variable in checkbox array [duplicate]

I'm working on selecting multiple checkboxes and store it to my database but when I call the name of the checkboxes which is array "living_whom[]" and store it to my variable in php the error say that "Undefined index: living_whom". I can't find what is problem. Here's the code:

             <div class="row">
                <div class="col-md-12">
                  <div class="form-group">
                    <label>Living with whom</span></label>
                    <div class="row">
                      <div class="col-md-2">
                        <label class="checkbox-inline">Parents
                          <input type="checkbox" name="living_whom[]" value="Parents">
                          <span class="checkmark"></span>
                        </label>
                      </div>
                      <div class="col-md-3">
                        <label class="checkbox-inline">Brothers & Sisters
                          <input type="checkbox" name="living_whom[]" value="Brothers & Sister">
                          <span class="checkmark"></span>
                        </label>
                      </div>
                      <div class="col-md-2">
                        <label class="checkbox-inline">Grandparents
                          <input type="checkbox" name="living_whom[]" value="Grandparents">
                          <span class="checkmark"></span>
                        </label>
                      </div>
                      <div class="col-md-2">
                        <label class="checkbox-inline">Other Relatives
                          <input type="checkbox" name="living_whom[]" value="Other Relatives">
                          <span class="checkmark"></span>
                        </label>
                      </div>
                      <div class="col-md-2">
                        <label class="checkbox-inline">Friends
                          <input type="checkbox" name="living_whom[]" value="Friends">
                          <span class="checkmark"></span>
                        </label>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

and when I get the name of the checkboxes in php:

 $living_whomArr = $_POST["living_whom"];

Thank you for the help!




mat-checkbox inside *ngFor is not working properly in material 6

I generating checkboxes inside *ngFor using Angular 6 Material 6. The checkbox are able to display properly. But when I clicked on any one of the checkboxes, it is flickering and not able to check it properly.

I tried it in stackblitz, where it is working properly. I don't know if anything I have missed. I am struggling from past one week.

I have imported it properly in app.module.ts like this:

import {MatCheckboxModule} from '@angular/material/checkbox';

This is my code. Please suggest me any dependencies other than this I need to include.

<div *ngFor="let prop of reflectUI; let i = index">
    <mat-checkbox>prop</mat-checkbox>
</div>

Please Guide me.




Additional space under checkbox element [duplicate]

Why is there additional space below checkbox? It is not identified in DevTools but expands its container on about 3-4 pixels. I've tested it in Firefox and Edge browsers, it seems that checkbox has inconsistencies in its visualization (Firefox doesn't change the size of it despite the height: 50px; width: 50px; I use Chrome 67 (on Windows 10). The problem seems the same in Edge. Here is JSFiddle: extra space below checkbox

* {
  box-sizing: border-box;
}

.container {
  border: solid 1px;
  padding: 0;
}

input {
  height: 60px;
  width: 60px;
  margin: 0;
}
<div class="container">
  <input type="checkbox" />
</div>



Use header check box for select all in infinite scolling using ag-grid angular 4

I would like to use a checkbox in the header of ag-grid for Select All option. The row model type i am using is infinite. I guess this model doesnt support headerCheckboxSelection=true. How else i can use a checkbox inside the header cell? I will be making a service call on click of this checkbox for further processing.




Check all the check boxes in recycler view [duplicate]

I have a recycler view that gets an array and creates a check box for every item of it. I would like a check box to be on the top of the recycler view which if it's checked, so all the check boxes of recycler view become checked, too. How can I reach that?

Recycler View Adapter:

class RecyclerViewAdapter(val context: Context, val myArray: Array<String>): RecyclerView.Adapter<RecyclerViewAdapter.Holder>(){
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val view = LayoutInflater.from(context).inflate(R.layout.recycler_view_pattern,parent,false)
        return Holder(view)
    }

    override fun getItemCount(): Int {
       return myArray.count()
    }

    override fun onBindViewHolder(holder: Holder, position: Int) {
       return holder.bind(myArray[position])
    }

    inner class Holder(itemView: View?): RecyclerView.ViewHolder(itemView){
        val checkBox = itemView?.findViewById<CheckBox>(R.id.checkBox)

        fun bind(str: String){
            checkBox?.text = str

            checkBox?.setOnCheckedChangeListener(object : CompoundButton.OnCheckedChangeListener{
                override fun onCheckedChanged(p0: CompoundButton?, p1: Boolean) {
                    if (checkBox.isChecked){
                       //do something
                    }
                    else{
                        //do something
                    }
                }
            })
        }
    }
}

Recycler View Pattern:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp">

<CheckBox
    android:id="@+id/checkBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000"
    android:textSize="14sp" />
</LinearLayout>




Creating Checkbox From a List or Dict with Tkinter

I have a dict that contains data and I need to create a checkbox. But because this dict is editable I don't know its contents of it in real life so I need something like a for loop. But while the structure of tkinter checkbox program like

CheckVar1 = IntVar()
CheckVar2 = IntVar()
C1 = Checkbutton(top, text = "Music", variable = CheckVar1, \
             onvalue = 1, offvalue = 0, height=5, \
             width = 20, )
C2 = Checkbutton(top, text = "Video", variable = CheckVar2, \
             onvalue = 1, offvalue = 0, height=5, \
             width = 20)

this I have no idea how to do it. Also I need to check which one is checked and which one is not, then create a list from them.

Thanks.




Save once checkbox value inside a checkbox loop

I have this code:

<?php
if(isset($_POST['submit'])) {
 if(isset($_POST['sharks'])) {
      $_SESSION['value'] = $_POST['sharks'];
  } else {
      $_SESSION['value'] = '';
  }
}
?>
<form action="" method="POST">
  <?php
  echo '<input name="sharks" type="checkbox" value="1" id="sharks" ';
    if ($_SESSION['value'] == 1) {
      echo ' checked="checked"';
    }
  echo ">";
  ?>
  <br>
  <button type="submit" name="submit" value="Save">Salva</button>
</form>

I'm already inside a loop of users, I just want to add a checkbox next to them and save the value of that checkbox connected to that user.
enter image description here

When I try to save the checkbox this is what happen:
enter image description here

Thank you all




How to do JQuery Ajax multiple checkbox with file upload and date

newbie here. I got a problem regarding how to insert multiple checkbox values together with upload file inside of the Ajax. I have tried all of the solutions on this website but none of them works. I`m using PHP with Mysqli. Now, I have created a code like this:

Form.php

<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" name="submit">

<input  type="text" id="project_name" placeholder="Project name . . ."/>

<input type="checkbox" id="check1" class="chk-btn" value="1"/>
<label for="check1">Number 1</label>

<input type="checkbox" id="check2" class="chk-btn" value="2"/>
<label for="check2">Number 2</label>

<input type="checkbox" id="check3" class="chk-btn" value="3"/>
<label for="check3">Number 3</label>

<input type="checkbox" id="check4" class="chk-btn" value="4"/>
<label for="check4">Number 4</label>

<input type="date" class="form-control" id="date" name="date"   

<button type = "submit" id="addnew" class ="btn btn-primary">Add</button>

</form>

Please help me, i`m a newbie in jQuery.




mardi 24 juillet 2018

How can i use checked box value in controller?

  • Actually, i`ve never studied HTML or programming language systematically. Now, I'm in a school club that develops web sites and i learned really really basic things. This summer, i am challenging making a small websites with club members.(with significance to the challenge :) ) So please let me know some kind of searching keyword or the simplest code (i only know RUBY) related to below contents. Thank you :)))

This is kind of calculator service. I made this kind of checkbox. I want to apply different formula depending on which one is checked.

def food @post = Post.find params[:post_id]

@result_rice = 1
@result_noodle = 2
@result_meat = 3

How can i set code in my controller? (I am sorry for the low standard of questions :( )




PHP - posting checkbox values foreach record

My html form has the following fields:

subscriberid - number input product category - select option typeofoutlet - 4 checkboxes.

Of this subscriberid is a static field. The html elements for product category and typeofoutlet are dynamically generated through a add record button.

enter image description here

I am trying to post the form data to mysql using PHP. The following is the code:

if(isset($_POST['submit'])){
    //connect to db
    $mysqli = NEW MySQLi('localhost', 'root','Abc@123def', 'tsl');
    $subscriberid = $_POST['subscriberid'];
    $category = $_POST['category'];
    $brand = $_POST['brand'];
    $kirana = $_POST['kirana'];
    $chemist = $_POST['chemist'];
    $mall = $_POST['mall'];
    $online = $_POST['online'];

    foreach($category as $key => $value) { 
            //perform insert
            $query = "insert into hhpurchase (subscriberid, category,brand,kirana,chemist,mall,online) 
                    VALUES (
                        '". $mysqli->real_escape_string($subscriberid) ."',
                        '". $mysqli->real_escape_string($category[$key]) ."',
                        '". $mysqli->real_escape_string($brand[$key]) ."',
                        '". $mysqli->real_escape_string($kirana[$key]) ."',
                        '". $mysqli->real_escape_string($chemist[$key]) ."',
                        '". $mysqli->real_escape_string($mall[$key]) ."',
                        '". $mysqli->real_escape_string($online[$key]) ."'        

            )";
            $insert = $mysqli->query($query);
            if(!$insert) {
                echo $mysqli-> error;
                echo "<script type='text/javascript'>alert('Submission failed!')
                window.location.href='test.php';
                </script>";
            } else {
                echo "<script type='text/javascript'>alert('Submitted successfully!')
                window.location.href='test.php';
                </script>";
            }
        }
        $mysqli->close(); 
    }

While all the records gets recorded correctly, the data from 4 check boxes gets stored in the one line irrespective of number of lines of data that I have in the form. The example output is as follows:

enter image description here

Now in the above image, the 1 under kirana is right, however, the 2 under chemist should be in row 2 but always gets posted in row 1. However, if I have two rows and for both of which if I have selected the same option, they are getting posted correctly.

The HTML for checkboxes is as follows:

<label>Kirana</label>
<input type="checkbox" name="kirana[]" id="kirana" value="1">
<label>Chemist</label>
<input type="checkbox" name="chemist[]" id="chemist" value="2">
<label>Mall</label>
<input type="checkbox" name="mall[]" id="mall" value="3">
<label>Online</label>
<input type="checkbox" name="online[]" id="online" value="4">