logo
down
shadow

How to find which checkboxes are selected and pass them to ActionResult in MVC?


How to find which checkboxes are selected and pass them to ActionResult in MVC?

By : Andy Hoang
Date : November 17 2020, 01:00 AM
help you fix your problem Assuming that you have a boolean property named IsSelected in your SubCatagory class. You should be to able send the values like this
code :
 var checkedList = $.map($(':input[name="Subcategory"]'),
   function(){
    var $this = $(this);
    return {
       name :$this.data('subcatagory'), // You can add the subcatagory as a data dash attribute or any other unique identifier in  html of the checkbox before appending
       IsSelected  : $this.is(':checked')
        }});
        $.ajax({
          url : '<your url>',
          type:"POST",
          contentType:"application/json; charset=utf-8",
          data : JSON.Stringify({
                  'Subcategories' :checkedList
                 })
        });


Share : facebook icon twitter icon
How to pass the values of the checkboxes to ActionResult in MVC5?

How to pass the values of the checkboxes to ActionResult in MVC5?


By : user2960124
Date : March 29 2020, 07:55 AM
help you fix your problem Change your RegisterBusiness Action to take a int array named subcategory
code :
public async Task<ActionResult> RegisterBusiness(BusinessViewModel model, int[] subcategory)
using System.Linq;
...
...
ICollection<Subcategory> Subcategories = subcategory.Select(x => new Subcategory { SubcategoryID = x}).ToList();
How to pass item id and DropDownList selected item value to ActionResult?

How to pass item id and DropDownList selected item value to ActionResult?


By : Bruno Castim Castim
Date : March 29 2020, 07:55 AM
To fix this issue @Html.DropDownList("StatusDDL", sl); is generating
How to post selected checkboxes from order form to ActionResult?

How to post selected checkboxes from order form to ActionResult?


By : Silver
Date : March 29 2020, 07:55 AM
Any of those help Model: , You need to store your selected date in cookie like below :
code :
<script>
            $.cookie('datascelta', dataValue);  //set datascelta
            $.cookie('datascelta');  //get datascelta

            $.cookie('datascelta1', dataValue1);  //set datascelta
            $.cookie('datascelta1');  //get datascelta



            $(function () {
                $.datepicker.setDefaults($.datepicker.regional['it']);
                $('#datetimepicker6').datetimepicker({
                    inline: true,
                    altField: '#datascelta',
                    defaultDate: $.cookie('datascelta') ? $.cookie('datascelta') : new Date() //get the date after reload and init datepicker
                    onSelect: function (dataValue) {
                        $.cookie('datascelta', dataValue); //store the date in cookies before submiting form
                    }
                });

                $('#datetimepicker7').datetimepicker({
                    inline: true,
                    altField: '#datascelta1',
                    defaultDate: $.cookie('datascelta1') ? $.cookie('datascelta1') : new Date() //get the date after reload and init datepicker
                    onSelect: function (dataValue1) {
                        $.cookie('datascelta1', dataValue1); //store the date in cookies before submiting form
                    }
                });

                $("#datetimepicker6").on("dp.change", function (e)
                {
                    $('#datetimepicker7').data("DateTimePicker").minDate(e.date);
                });
                $("#datetimepicker7").on("dp.change", function (e)
                {
                    $('#datetimepicker6').data("DateTimePicker").maxDate(e.date);
                });
            });
</script>
Table with Checkboxes - selected all Checkboxes and pass values to AJAX script

Table with Checkboxes - selected all Checkboxes and pass values to AJAX script


By : Max Schrieks
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I have a table with a checkbox in the first column - when checked this performs an AJAX script that updates a PHP session variable with the selected values. This is all working well but I now need to extend this to have a check box at the top of the first column to allow the user to select all items in the table and pass the value of the selected items (e.g. comma separated) as a parameter to the AJAX script - assuming I need a new script just for this.
code :
$('.select-all').on('click', function(){
    var values = []; // will contain all checkbox values that you can send via ajax
    $('table > tbody input[type="checkbox"]').each(function(i, el) {
        $(el).prop('checked', true);
        values.push(el.value);
    });
});
Why won't my checkboxes appear selected when I pass the correct data into them?

Why won't my checkboxes appear selected when I pass the correct data into them?


By : nubututu
Date : March 29 2020, 07:55 AM
should help you out So I have a table that is suppose to reflect data that is passed in from sql and one of these data fields is a boolean that is supposed to be shown by a checkbox , Use ng-checked directive of angular like following:
code :
<input name="DidPass" type="checkbox" ng-checked="task.DidPass == 1" ng-model="task.DidPass" ng-true-value="1" ng-false-value="0">{{task.DidPass}}
Related Posts Related Posts :
  • In HTML5, please explain the meaning of '?' in the statement
  • Form to use AJAX rather than a page refresh but also utilise error handling?
  • JQuery Script looping error
  • different size divs align top left
  • Image fade-in when webpage finishes loading
  • Seeking HTML5 audio element causes delay (breaks sync)
  • How can I read & write data to a new tab in Firefox?
  • jQuery or JS turn all words into italic type
  • iOS css -webkit-transform: scale doesn't offset touch events
  • Populate select list using javascript
  • Can you work out why my .js file doesn't seem to be linking to my html?
  • Make slideToggle effect only one element at a time
  • Output sound using JavaScript
  • What is the analytics.js equivalent of _trackPageview found in ga.js
  • How can I check if a JS file has been included already?
  • hasClass and condition not working
  • EDITED: I'm having issues with a button and its function
  • Importing XML in HTML with javascript
  • Create new function in contentScriptFile in Firefox extension
  • Should I build Node.js from source or download the OS X installer?
  • How to enforce integer sizes in JS? (TypeScript?)
  • How to update the JSON object without deleting old values using javascript
  • Reading a javascript variable containing a string into another file
  • Possible to prevent 403 errors from logging to the web console?
  • Jquery Accordion - Expand and collapse div on hover
  • jquery .hide() function - Hide mobile, Display Desktop
  • Holding password in javascript variable - security implications?
  • JQPlot trouble to render vertical stacked bar and horizontal legend
  • counts days inbetween then add class to those days with nested divs?
  • Marionette.js with Rails (Devise) Authentication
  • javascript anonymous function evaluation idiom
  • Why am I losing the decimal when working this equation in Javascript?
  • Site redirects to index.php after being open while making calls to an API using AJAX
  • How to determine when multiple callbacks are all done
  • How to update Yeoman dependencies?
  • How can I do a /resolve with the Soundcloud Javascript SDK?
  • I'm not able to call a named callback function
  • How to get value of Paragraph element contained in <div> in HTML using JavaScript
  • Javascript - Get value from textbox and save it on a string
  • Backbonejs collection not populated, but fetch works
  • when function's internal [[scope]] property is assigned?
  • Wrapping around the edges in a 2d array (game of life)?
  • Clone div with all nested elements along with events in pure javascript
  • How to get response text?
  • Setting and retrieving cookies in javascript
  • Passing parameter with double quotes
  • finding the meaning of the obfuscated javascript
  • Socket.io - Sending data from a pusher stream to the client
  • How to determine the visibility li's in a scrollable ul
  • How to create Scrolling Effect like Grouek website
  • How to display a state in parents template in ui-router
  • Angular ng-repeat - creating collection dynamically
  • finding advertisements on a page with javascript
  • Is there a way to cause a Grunt plugin to fail if input files are missing?
  • JQuery datepickers- setting end date from a start date
  • javascript - explanation request of a behaviour
  • Converting String into date format in JS
  • Choose element Angular
  • Display background grid by using image with CSS
  • Call function from another Controller in another file AngularJS
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org