logo
down
shadow

Checkbox clicking works, deselecting checkbox not working Javascript


Checkbox clicking works, deselecting checkbox not working Javascript

By : Jason Parr
Date : November 29 2020, 09:01 AM
may help you . While deselect the checkbox you again set the result value. Calculate the value based on page value.
Please try below code.
code :
function calculate() 
{
   var myBox1 = document.getElementById('pages').value;
   if(isNaN(myBox1))
   {
      alert('Enter only numbers');
   }
   else
   {
      const myBox2=2;
      var result = document.getElementById('result');   
      var myResult = myBox1 * myBox2;
      result.value = myResult;
    }   
}

function checkbox1()
{
   var result1 = document.getElementById('result').value;
   const bresult=result1;
   if(document.getElementById('ckbox').checked === true)
   {
      const checks=3;
      var myResult1=result1 * checks;
      result.value = myResult1;
   }
   else
   {
       var myBox1 = document.getElementById('pages').value;
       const myBox2=2;
       result.value=myBox1 * myBox2;
   }
}
<table>
    <tr>
        <td>Number of Pages</td>
        <td>Check Boxes</td>
        <td>Total</td>
    </tr>    

    <tr>
        <td><input id="pages" type="text" oninput="calculate()" /></td>
        <td><input type="checkbox" id="ckbox"   onclick="checkbox1()">Assistance</td>
        <td><input id="result" /></td>
    </tr>
</table>


Share : facebook icon twitter icon
Disable/enable one checkbox on deselecting other checkbox in jsf?

Disable/enable one checkbox on deselecting other checkbox in jsf?


By : user3474584
Date : March 29 2020, 07:55 AM
wish helps you 1) , change
code :
<p:ajax event="change" update="continuous" />
<p:ajax event="click" update="continuous" />
Javascript check/uncheck all checkbox function only works when there is more than one checkbox

Javascript check/uncheck all checkbox function only works when there is more than one checkbox


By : James Cannon
Date : March 29 2020, 07:55 AM
will be helpful for those in need I've got a series of checkboxes set up as an array (name="action[]") and a JavaScript function linked to another checkbox to check/uncheck all of them. It works fine when there are at least two checkboxes to be checked, but if there's only one it does nothing. Can anyone point me in the right direction? !
code :
<input type="checkbox" name="checkall" id="checkall" class="box">

<input type="checkbox" name="action[]" id="action" value="' . $something['someid'] . '" class="box check-child">
<input type="checkbox" name="action[]" id="action" value="' . $something['someid'] . '" class="box check-child">
$("#checkall").click(function(){
    if($(this).is(":checked"))
        $(".check-child").attr("checked", "checked");
    else
        $(".check-child").removeAttr("checked");
));
JQuery - Clicking on checkbox container works, clicking on checkbox doesn't

JQuery - Clicking on checkbox container works, clicking on checkbox doesn't


By : Basit ali
Date : March 29 2020, 07:55 AM
Hope that helps Here: http://jsfiddle.net/umidbek_karimov/y84ne/
1: Wrap Your input[checkbox] in to label:
code :
<label><input type="checkbox" value="App1" />App1</label>
$(document).ready(function () {
    $(".dropdown-menu li label").click(function (ev) {
        ev.stopPropagation();
    });
});
#advanced_options label {
    font-weight:normal !important;
    font-family: Tahoma, Geneva, sans-serif;
    display:block;
    cursor: pointer;
}
Checkbox issue where clicking on Checkbox 3 marks Checkbox 1 and etc

Checkbox issue where clicking on Checkbox 3 marks Checkbox 1 and etc


By : user3645501
Date : March 29 2020, 07:55 AM
may help you . You should change the Ids of input checkboxes and for values of labels.
code :
<tr>
<td><input type="checkbox" id="checkbox65" class="css-checkbox med" />
    <label for="checkbox65" class="css-label med elegant" name="avatar" value="image1"/></label></td>
<td><input type="checkbox" id="checkbox66" class="css-checkbox med" />
    <label for="checkbox66" class="css-label med elegant" name="avatar" value="image2"/></label></td>
<td><input type="checkbox" id="checkbox67" class="css-checkbox med"/>
    <label for="checkbox67" class="css-label med elegant"  name="avatar" value="image3"></label></td>
</tr>
How to deselect the select all checkbox when i am deselecting even 1 checkbox in android

How to deselect the select all checkbox when i am deselecting even 1 checkbox in android


By : marcel
Date : March 29 2020, 07:55 AM
should help you out You can set OnCheckedChangeListener on holder.cbSelect. in your adapter.
code :
holder.cbSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    dataList.get(holder.getAdapterPosition()).setSelected(isChecked);
                    // here you can call listener to get notified 
            }
        });
    }
public interface OnMyCheckBoxCheckedChangeListener {
    void onMyCheckBoxCheckedChange();
}
private OnMyCheckBoxCheckedChangeListener mOnMyCheckBoxCheckedChangeListener;

    public YourAdapter(..., ..., OnMyCheckBoxCheckedChangeListener onMyCheckBoxCheckedChangeListener) {
            mOnMyCheckBoxCheckedChangeListener = onMyCheckBoxCheckedChangeListener;
        }
holder.cbSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    dataList.get(holder.getAdapterPosition()).setSelected(isChecked);
                    mOnMyCheckBoxCheckedChangeListener.onMyCheckBoxCheckedChange(); 
            }
        });
    }
yourRecyclerView.setAdapter(new YourAdapter(..., ..., new OnMyCheckBoxCheckedChangeListener() {
    @Override
    public void onMyCheckBoxCheckedChange() {
        // you will get notified here.
    }
}));
Related Posts Related Posts :
  • CRM 2013 Limit the date field
  • fancybox - changing close button color
  • Ember-notify giving error can't read property "Service" of undefined
  • Passport-init.js authentication is not working in nodejs
  • Branch.io Cordova API - init() fails on Android Device
  • appending HTML codes to an elements using js
  • Css animation to extend button text on hover
  • I want to restrict HTML input autocomplete to 3 letter minimum
  • tinyMCE editor not updating on the fly
  • typescript kendo-ui call method from string
  • HttpCompileException was unhandled by user code (when i am adding c# code in script)
  • Send form data as array of objects to controller in asp.net mvc
  • Javascript, multi file modules and Require.Js
  • how to render a complete new template and leave the application template in ember
  • Hover unrelated divs
  • Permute string until it matches some input?
  • How to fire JQuery change event when input value changed programmatically?
  • AJAX: POST data to a different url
  • checkbox column in jquery datatable
  • Document.evaluate for documents without namespaceURI crashes Microsoft Edge
  • Bootstrap Menu with "More" option Responsive issue
  • Standard inputs not being added to Angularjs Form $Scope
  • Express promise throw error
  • onclick and get in jquery
  • How to get the country code from Google Places API
  • Passing parameters url in Select2
  • Is there any frame work for Marklogic to write javascript code?
  • How to implement a boostrap template over bootstrap-sass gem
  • Why fixed div comes out when horizontally scrolled?
  • How to limit scope of a function in javascript/ jquery
  • Overlapping legend d3.js
  • Apply transition to div
  • Javascript game help - counting with dice
  • How to hide a div from angular controller
  • Can Promise load multi urls in order?
  • How enable Hover event for bootstrap menus?
  • D3 scale.invert() isn't returning date for x
  • Parsing object to array using underscore js or lodash
  • ES6 with React and Browserify
  • AngularJS Factory return type undefined
  • javascript follow html input fields
  • how to declare a double array in javascript for this particular UI
  • Jquery : find length of mixed list
  • Returning the array before the function is complete & Angular JS
  • Javascript set value of class & hidden input in nested divs
  • Register custom filters with vue.js
  • Add class to input parent
  • Angular controller not talking to view
  • Trouble creating "if then" Javascript statement to change background color of page
  • Socket.IO - Middleware and scoping: how should I access global IO object from external middleware?
  • add class when input is valid in angularjs
  • Positioning multiple div elements
  • Adding ajax jQuery File upload
  • Creating a dynamic array within a dynamic array in JQuery
  • Multiple File Upload actions for a single File Input PHP/JS
  • Want to move an added element to a different part of the DOM
  • Why can't I get Angularjs to work?
  • Minimizing browser window in Firefox & Chrome adds white space to right of page
  • I need to insert the date and time of employee stamp in and out into mysql database
  • Making css auto slider
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co